How do I increment a folder name using Windows batch command?
I have multiple folders at some path in a particular format like Release Version(1.060) I want to create new folder with name - Release Version(1.063)
How do I increment a folder name using Windows batch command?
I have multiple folders at some path in a particular format like Release Version(1.060) I want to create new folder with name - Release Version(1.063)
list the folders (/b = name only, /ad = folders only, /on = sort by name), get the version number with a for /f loop, add one to the minor number (note the trick to handle leading zeros: add a 1 in front of it, add one and get the last three chars). Then simply reassemble the new version number:
@echo off
for /f "tokens=2,3 delims=(.)" %%a in ('dir /b /ad /on "Release Version*"') do (
set "major=%%a
set "minor=1%%b"
)
set /a minor+=1
set "minor=%minor:~-3%"
echo new release version is "%major%.%minor%"
md "Release Version(%major%.%minor%)"
Of course, this depends on the exact format: Release Version(x.yyy).