'Add number prefix to file names in a folder, based on the last prefix number
I have a folder with 10 files. I have been able to rename them all using a script I created to add '1 - ' at the beginning of the file names in order. So, each file starts with '1 - ', '2 - ' etc.
Two questions here:
When I re run the script, it does not recognise that the file already has a '1 - ' at the start and so it just adds another 'X - ' at the start of it again. E.g. '1 - 2 - XXXX'
I would like to add to the script to say, where the file already has a prefix of '1 - ' (1 can be any number), then the script should not rename it again (like point 1 above)
Finally, if I add any new files into the same folder, I would like the new files to have the prefix number from the last number in the folder e.g.
Folder contains:
1 - XXXX 2 - XXXX 3 - XXX
If I add a fourth file and run the script the new output should be:
1 - XXXX 2 - XXXX 3 - XXX 4 - XXX
Previous files are not affected and the new file starts at 4.
Any help would be appreciated!
UPDATE: As requested, I have added my current script here: enter image description here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
