Rename a File (.png) with script

Hi, I'm not super familiar with scripting, and I don't see a way to do what I want with the MV.

I'm trying to figure out if there's a way to rename a file, in particular, a png.
is it possible to do this once the game has been compiled?

This is so I can allow the player to choose pre-made characters for Player 1.
Each png will have 8 expressions of one player model. (Player1.png, Player2.png...etc)

Then have the player choose a Character, i.e. Player 3, and I can just rewrite Player3.png to Player1.png
Not sure if this is enough information.
Thanks!

Oats
Using the Node Filesystem module you can rename files:

https://nodejs.org/api/fs.html#fs_fs_rename_oldpath_newpath_callback

Note this only works for desktop deployments and it permanently overwrites the file. If Player3.png is renamed to Player1.png then the old Player1.png is completely gone. And if the player starts a new game, there is no Player3.png anymore.
Alternatively, based on what you've said, you may want to consider using the Change Actor Images event command to change the faceset associated with that actor. Then you can use a plugin like Yanfly's Message Core + Extended Message Pack 1 or Shaz's More Escape Codes to specify the face index (i.e. the facial expression) via a message code. 🙂

Also, in case it comes in handy: you can have more than 8 faces per faceset if you manually edit the image. Just add more rows (144 px row height) and the editor should recognise them! 🙏
Wow, both excellent and informative answers. Thanks a lot Aloe and caethyril! I will try them soon

Oats

Original thread: https://forums.rpgmakerweb.com/threads/rename-a-file-png-with-script.110407/