Trouble renaming tileset filename

I want to change the filename of a .tsx and I’ve tried going to Tileset menu > Tileset Properties and changed the name there, but what I want really is to change the filename. I tried to rename it manually in the file explorer, but it seems like it makes a new .tsx and Tiled just ignores it when exporting map/.tmx files, it keeps using the old name. I’ve also noticed there is a exportfilename variable so I tried exporting it with a new name to see if it would make any difference, but nothing.
How can I change my tileset’s name, filename and exportfilename when exporting it to a lua file?

You can rename the file, but your maps still have references saved to the old name, so you’ll need to update those. The easiest way is, after renaming your TSX, to open the maps that use it. Then, Tiled will prompt you for the missing tileset, and you can select the newly renamed file. If Tiled doesn’t prompt you, you can navigate to the old/missing tileset in the Tilesets panel, and then click the “Replace Tileset” button to replace it with the renamed tileset.

Alright, thanks!
And same thing but for the tmx file, how would be the most appropriate way to rename its filename? i.e. old name is “hsauhsahu.tmx” and new name is “example_map.tmx”.
Without breaking everything, I mean.
(Also, I assume clicking in the trash button will remove any mentions and information of that tileset?)

Worlds are the only Tiled files that refer to other maps, I think, unless you made some manual references yourself (e.g. in rules.txt for Automapping, or in custom properties). I don’t think there’s any built-in way to update a reference to a map in the world. One option is to remove the map from the world prior to renaming, and then add it again after renaming. Another option is to edit the World file in a text editor to update the map name. You’ll want to close Tiled or unload the World while you do this, to prevent Tiled from overwriting your changes.

Aside from that, you should be able to just close the map, rename the file in your OS, and then open the newly renamed file in Tiled.

(Also, I assume clicking in the trash button will remove any mentions and information of that tileset?)

Yes. You’ll be warned if any tiles from that tileset are still in use.
Edit: Note that this is a per-map action, it only removes that tileset from that one map.