Reputation: 1
There is a huge amount of pdf files in my datacenter's subdirectories. In a local folder i want to check if the existing files are already in the datacenter's dir and if yes to move them to another local folder. I want to filter my search to .pdf files that have been modified today, otherwise the whole search thing in datacenter's subdirs takes ages.
@echo off
pushD \\server\pdf
for /r %%i in ( *.pdf ) do (
if exist "%userprofile%\desktop\F1\%%~nxi" ( move /y "%userprofile%\desktop\F1\%%~nxi" %userprofile%\desktop\F3
) else echo File %%~nxi is not a duplicate
)
popD
pause
What should i add to above for command ?
Upvotes: -1
Views: 55
Reputation: 38719
You already know about the ForFiles
command, mentioning it in your duplicate question on DosTips; so why not use it?
PushD "\\server\pdf" 2>Nul && (
ForFiles /S /M *.pdf /D 0 /C "Cmd /C If Exist \"%UserProfile%\Desktop\F1\@File\" If Not Exist \"%UserProfile%\Desktop\F3\@File\" Move \"%UserProfile%\Desktop\F1\@File\" \"%UserProfile%\Desktop\F3\""
PopD)
If you prefer you could use Move
with the /Y
option or you could forget about the If Exist
and just supress error messages, but the general idea should work for you.
Upvotes: 0