Reputation: 305
Below is the code to copy files from one folder to another folder and it works. However,I get new files generated everyday with small change in name. This code does not copy those new files when filename is simply modified.
@echo off
setlocal disableDelayedExpansion
set "file="
for /f "eol=: delims=" %%F in ('xcopy /dl "C:\Users\TMM\Desktop\fol2\*" "\\Folder2\TS\Test"') do (
if defined file (
setlocal enableDelayedExpansion
copy "!file!" "\\Folder2\TS\Test" >nul && echo "!file!" || echo FAILED: "!file!"
endlocal
)
set "file=%%F"
)
Upvotes: 0
Views: 67
Reputation: 6659
Use the robocopy mirror feature. DestDir will be maintained as a mirror of source dir, including removing files from destDir that no longer exist in sourceDir.
robocopy sourceDir destDir /S /MIR
Upvotes: 1