-1

我正在寻找一个批处理文件,它将检查目标目录中文件的日期,如果源目录中的文件副本较新,则重命名目标目录中的现有文件,然后从源中复制新文件. 我知道 xcopy /d 将处理文件的副本,但我不确定其余的。

4

1 回答 1

1

您可以使用 XCOPY /L 选项获取将被复制的文件列表,并使用 FOR /F 处理该列表。

@echo off
setlocal
set "source=sourcePath"
set "dest=destinationPath"
for /f "eol=: delims=" %%F in ('xcopy /d /l "%source%\*" "%dest%\"') do (
  if exist "%%F" ( %= This IF weeds out the file count summary at the end =%
    if exist "%dest%\%%~nxF" ren "%dest%\%%~nxF" "someNewName"
    copy "%%F" "%dest%\"
  )
)
于 2013-10-22T21:32:13.237 回答