我在SE上找到了以下批处理脚本:
Batch Script - IF EXIST copy to %localappdata% error
IF EXIST "%localappdata%\foldername\filename" (COPY /Y "filename" "location")
如何修改脚本以对充满文件的目录进行操作?我试过了,但它没有工作:
IF EXIST "temp\*.*" (COPY /Y "artwork\*.*" "temp")
答案 0 :(得分:2)
XHR
命令包含更新开关,仅复制目标文件夹中已存在的文件。
xcopy
答案 1 :(得分:1)
你可以尝试这样的事情:
@echo off
set "FolderSource=%localappdata%\FolderTest"
Set "Target=%~dp0Location"
IF Not EXIST "%FolderSource%" echo "%FolderSource%" does not exist & pause>nul & exit
If Not Exist "%Target%" MD "%Target%"
For /f "delims=" %%a in ('Dir /b /s "%FolderSource%\*.*"') Do (
IF EXIST "%Target%\%%a" ( COPY /Y "%%a" "%Target%"
) ELSE ( COPY "%%a" "%Target%"
)
)
pause>nul