我有一个.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