I'm currently writing a windows batch file which needs to check if a folder with the current computer name exists. If it doesn't, it writes the folder with the name, but if it is already there, it appends a number at the end so that in the end I'd have a folder containing folder names like this
G:\logs\computer-1 G:\logs\computer-2 G:\logs\computer-3 G:\logs\...
so far, I tried using this piece of code
set usb=G: SET logdir="%usb%\logs\%computername%" FOR /L %%F IN (1,1,25) DO ( IF NOT EXIST "%usb%\logs\%computername%-%%F" ( md "%usb%\logs\%computername%-%%F" SET logdir=%usb%\logs\%computername%-%%F) goto :eof ) ECHO %logdir%
but all I manage to do is exit the loop, not something I want to do.