computing
  • 15

DOS Batch If File Exists Rename Sequentially

  • 15

Hello all,
I am creating a DOS Batch file to process large collections of archive files. The batch un-archives each file and re-archives each file individually to zip format. Once I have a zip I want to move them to a destination directory. Before the move occurs I’d like to test if that exact zip file name exists. If it exists, I will need to increment the filename sequentially and then test again. I’ve found several examples of sequentially incrementing file names in a for loop, but not one that will allow me to test the filename again (2nd, 3rd, 4th, etc times) and increase the filename sequentially to come up with a unique filename.

Any ideas? I’m reluctant to post broken code but I can show you what I’ve got if you need to see more. Many thanks!

Share

1 Answer

  1. You could restart the program again by using this:

    START “BATCHFILENAME.BAT”
    EXIT

    Try replacing the “goto :test” line with the above 2 lines. Leave the quotes around BATCHFILENAME, or the program won’t work right.

    Mouse could not be found. Click OK to continue.
    What to do now?

    • 0