我有一個.bat腳本。 &在該腳本「設置目標文件夾」&「set sourcefolder」命令在那裏。 我想刪除這兩個命令&想要在腳本執行後給這些命令。意味着它應該問問目標文件夾和sourceflder路徑。.bat Windows 7的批處理文件命令
因爲,我有任務的n個不同& & Targefolder路徑sourcefolder但是腳本做同樣的功能&對於那些所有的任務,我將不得不創造scripts..so,我想而不是要做到這一點,我可以保持批處理文件中的內容相同,並且只能放置目標文件夾源文件夾路徑。
總之,腳本應該問問目標文件夾& sourcefolder,在給出那些路徑後應該是完整的腳本。
那麼,有沒有人可以建議我該怎麼做?請
腳本有以下containt:
@echo off
setlocal
set DateFolder=04.2013
set TargetFolder=F:\Financial\Data\%DateFolder%\Final Reports
:: copy the newest file from AccruntPnLMTD and rename it to PNL.csv
call :copyAndRename "F:\Financial\Data\Reports\AccruntPnLMTD" "%TargetFolder%\PNL.csv"
:: copy the newest file from AccountPnlMTD and rename it to AC.csv
call :copyAndRename "F:\Financial\Data\Reports\AccountPnlMTD" "%TargetFolder%\AC.csv"
:: copy the newest file from ExpensesMTD and rename it to EXPMTD.csv
call :copyAndRename "F:\Financial\Data\Reports\ExpensesMTD" "%TargetFolder%\EXPMTD.csv"
:: copy the newest file from ExpensesYTD and rename it to EXPYTD.csv
call :copyAndRename "F:\Financial\Data\Reports\ExpensesYTD" "%TargetFolder%\EXPYTD.csv"
:: copy the newest file from AccrualPnLYTD and rename it to PNLYTD.csv
call :copyAndRename "F:\Financial\Data\Reports\AccrualPnLYTD" "%TargetFolder%\PNLYTD.csv"
:: copy the newest file from AccountYTD and rename it to ACYTD.csv
call :copyAndRename "F:\Financial\Data\Reports\AccountYTD" "%TargetFolder%\ACYTD.csv"
:: copy the newest file from BalanceMTD and rename it to BSMTD.csv
call :copyAndRename "F:\Financial\Data\Reports\BalanceMTD" "%TargetFolder%\BSMTD.csv"
:: copy the newest file from BalanceYTD and rename it to BSYTD.csv
call :copyAndRename "F:\Financial\Data\Reports\BalanceYTD" "%TargetFolder%\BSYTD.csv"
:: copy the newest file from FinancialStmtMTD and rename it to FSMTD.csv
call :copyAndRename "F:\Financial\Data\Reports\FinancialStmtMTD" "%TargetFolder%\FSMTD.csv"
:: copy the newest file from FinancialStmtYTD and rename it to FSYTD.csv
call :copyAndRename "F:\Financial\Data\Reports\FinancialStmtYTD" "%TargetFolder%\FSYTD.csv"
:: Done
goto :eof
:copyAndRename
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"
:: copy and rename it to the target
copy "%SourceFolder%\%NewestFile%" "%TargetFile%"
:: Done with this subroutine
goto :eof
你應該澄清你的問題,它幾乎是不可讀的。 – Endoro 2013-05-14 11:48:39
嗨Endoro,我已經更新了包含的腳本.. – 2013-05-14 15:02:40
好的。是否重命名爲PNL.csv的最新文件的源文件夾始終爲F:\ Financial \ Data \ Reports \ AccruntPnLMTD?列出的其他文件也是如此。 – 2013-05-20 17:37:23