How to iterate and Check for existence of files in directories MS-DOS
I would like to be able to itereate through all files in a directory. For each file I iterate over I would like to check to see if that file exists in another directory. However everything I try fails. As of right now I have the following code.
set base1="c:\documents and settings\pp57542\My Documents\Oracle Readings"
set send1="L:\Documents\Expert Book\Expert Book"
title Backup Script for Startup Routine Step 1
FOR /r %base1% %%c in (*.pdf) DO (if not exist %send1%\%%~nc (echo "Did not exist" & @xcop开发者_高级运维y %%c %send1% /Y /I /S))
pause
Where am I going wrong?
Would you believe you were one character off? x
in %%~nxc
stands for the extension (.pdf).
FOR /r %base1% %%c in (*.pdf) DO (if not exist %send1%\%%~nxc (echo "Did not exist" & @xcopy %%c %send1% /Y /I /S))
Hope that works for you.
精彩评论