How do I get the current save index your playing

This thread with help anyone who wants to help me. https://forums.rpgmakerweb.com/index.php?threads/delete-save-file-automatically.101850/

Well the title says it all. I am trying to get the current index using the script call:

StorageManager.remove(index);

Basically, I am trying to delete the current save upon game over, seeing if I can create a permadeath mode for my game I am working on. Thank you to anyone who may be able to help me.
You should be able to use 'DataManager.latestSavefileId()' to nab the last save file ID. However, are you limiting the amount of save slots the player can use in any way? What if the player has multiple saves which all have the current game data? Deleting the last/current save would not do much since the player could simply load another slot.
You make a good point. I guess I would have to limit the save files in some way. I just use an auto-save feature that I would like to keep as people generally don't like to have to work hard to save there progress, in my game it auto saves on each map to solve that for you. I just also wouldn't mind a permadeath feature for my game which is a single actor game. I'll have to think harder about this and thank you for helping me with that script call!
The approach you might want to use is to make sure the player can only save into the same exact save file that they loaded. I believe this would create a paradigm of One Save File Per Playthrough, which would allow you to delete the entire playthrough if the player dies, unless the player directly went into their files and copy/pasted stuff at some point.
Oh yeah you know what I did not even think about players doing that, but makes total sense. I guess I may need to commission a plugin for this.
You can just save to slot one automatically upon hitting "Save" and during game over delete that save. You don't have to open the save menu.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-get-the-current-save-index-your-playing.115327/