How to delete unused txt files and folders at runtime? (SOLVED)

I have been working to implement a save system in my game. Currently, I have every new profile create a new txt file and folder to save and load data with. When a profile is deleted, I want the associated txt file deleted too. I didn’t think about this initially and after about 2 months of work, I realizing I now have 454 save files from various tests and playthroughs.

How can I delete unused txt files or better yet, the folder they are held in? Is this even possible in Defold?

Thanks :slight_smile:

os.remove() will delete an individual file. You also have the LuaFileSystem extension which allows you to iterate and list files and folders.

1 Like

Perfect, thank you!