Sunday, February 6, 2011

script in CMD to copy only files that don't already exist

The following script will be written to copy.bat or something like that. When it runs it will copy the files that don't exist yet and skip them if the file does exist. This way it won't accidentally overwrite the file after you make changes to it.
set file=copy_mike.pdf
call:copy
set file=copy_jim.pdf
call:copy
set file=copy_bob.pdf
call:copy

echo done
pause
goto :EOF

:copy
if not exist %file% (
call:process
)
goto :EOF

:process
copy blank.pdf %file%

No comments: