Hey Experts. Working on a new script that will copy files from dir1 to dir2 but if the file being copied from dir1 to dir2 already exists in dir2, the file is moved to the Archive dir and then the copy job continues.
I can't seem to figure out the proper scripting for this. Your help in accomplishing this would be appreciated. Thanks Experts!
I found this but am having some trouble tweaking it to match what I wanted. I grabbed it from http://stackoverflow.com/questions/13254256/search-then-copy-and-to-location-rename-if-exit
and am still making changes.
FOR /F "usebackq delims=;" %%I IN (`dir C:\Test\DIR1\*.* /s /b`) DO (
IF NOT EXIST "C:\Test\DIR1\%%~nxI" (
CALL :COPYFILE "%%I"
) ELSE (
CALL :RENAME "%%I"
COPY "%1" "C:\Test\DIR2"
FOR /L %%N IN (1, 1, 1000) DO (
IF NOT EXIST "j:\@PCBackup\PST\%~n1%%N%<wbr ></wbr>~x1" (
COPY "%1" "j:\@PCBackup\PST\%~n1%%N%<wbr ></wbr>~x1"