2013-10-22 55 views
-1

我期待創建一個批處理文件,將檢查目標目錄中的文件的日期,如果源目錄中的文件的副本更新重命名目標中的現有文件目錄,然後從源中複製新文件。我知道xcopy/d會處理文件的副本,但我不確定其餘部分。批處理文件複製和重命名如果

+0

在Windows上,對吧? –

回答

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%\" 
) 
)