Solved Xcopy with folder rename if exist

July 15, 2014 at 08:11:04
Specs: Windows 7
I want to make a batch file to copy a directory to another folder, using "xcopy", but I want the batch file to check first if the destination directory already exists, then to rename the new copied directory by appending 1 to it and so on subsequently.

See More: Xcopy with folder rename if exist

Report •

#1
July 16, 2014 at 07:30:14
✔ Best Answer
:: I'll leave it to you to nuke out the xcopy bit.
::
::
::
::====== script starts here ===============
:: sequential backup folder numbers
:: SEQ!back.bat 2014-07-16 21:17:36.77
@echo off & setLocal enableDELAYedeXpansioN

for /L %%a in (1 1 1000) do (
if not exist d:\bak\mypix%%a (
set DEST=d:\bak\mypix%%a
goto :done
)
)
:done
echo.DEST is !DEST!
goto :eof
::====== script ends here =================

=====================
M2 Golden-Triangle


Report •

#2
July 30, 2014 at 22:35:17
Many thanks. Perfect.I did it.

Report •
Related Solutions


Ask Question