0
如果我通過腳本將文件移動到其他位置,文件會自動覆蓋,如果文件的名稱已經存在,則會自動覆蓋。 我應該在腳本中包含什麼命令,以便在覆蓋同一個文件之前詢問?如何在腳本中包含命令askinge「是否要覆蓋」文件
@echo off
setlocal
call "H:\data\datefolder"
set TargetFolder=H:\data\%DateFolder%\final reports
call :moveAndRename "H:\data\final\XYZfolder" "%TargetFolder%\Xyz.csv"
call :moveAndRename "H:\data\final\XYZfolder2" "%TargetFolder%\Xyz2.csv"
:: Done
goto :eof
:moveAndRename
set SourceFolder=%~1
set TargetFile=%~2
:: Find the newest file in the source folder
for /f "tokens=*" %%F in ('dir /b /od /a-d "%SourceFolder%"') do set "NewestFile=%%F"
:: move and rename it to the target
copy "%SourceFolder%\%NewestFile%" "%TargetFile%"
Pause
:: Done with this subroutine
goto :eof
嗨Endoro thx求助,我已更新我的codng到問題中。你可以讓我知道我可以包括那個命令嗎? – user2195198