Created
November 24, 2015 18:52
-
-
Save MarioLiebisch/c92bd0123b445a406dfd to your computer and use it in GitHub Desktop.
Windows batch: Get the next free numbered file name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
REM Initialize the first/lowest number | |
set NUMBER=0 | |
REM Jump point: return here if the current file exists | |
:LOOP | |
REM Leave the loop in case the file doesn't exist | |
if not exist backup-%NUMBER%.zip goto DONE | |
REM Increment the counter | |
set /a NUMBER+=1 | |
REM Well, loop... | |
goto LOOP | |
REM Jump point: we're done | |
:DONE | |
REM Now do something with the "next free numbered file" | |
move backup.zipe backup-%NUMBER%.zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment