批量使用FOR
循环重命名和压缩文件夹中存在的多个文件时,我遇到问题。
它的第一个迭代工作正常,并且可以根据需要重命名文件,但是在第二个迭代中,它不会重命名文件,而是继续进行。
我正在使用以下代码:
set logfile=C:\Oracle\"EPM Automate"\bin\IndianaAutomation\Logs\DataLoad_log.txt
echo Data Load started %date% %time% >> %logfile%
cd C:\Oracle\EPM Automate\bin\IndianaAutomation\PS_Source_Data
for %%g in (*.csv) do (
echo Process started for %%g >> %logfile%
ren %%g DataloadFile.csv
echo "zipping the Data File" >> %logfile%
"C:\Program Files (x86)\Common Files\Adobe\OOBE\PDApp\CCM\tools\7za.exe" a C:\Oracle\"EPM Automate"\bin\IndianaAutomation\PS_Source_Data\DataloadFile.zip C:\Oracle\"EPM Automate"\bin\IndianaAutomation\PS_Source_Data\DataloadFile.csv
echo "zipped the Data File" >> %logfile%
echo -- Moving files to Backup folder - %time% >> %logfile%
cd C:\Oracle\"EPM Automate"\bin\IndianaAutomation\PS_Source_Data
del DataloadFile.zip
ren DataloadFile.csv %%g
move C:\Oracle\"EPM Automate"\bin\IndianaAutomation\PS_Source_Data\%%g C:\Oracle\"EPM Automate"\bin\IndianaAutomation\PS_Source_Archive
echo -- Renaming files with current date - %time% >> %logfile%
C:
cd C:\Oracle\"EPM Automate"\bin\IndianaAutomation\PS_Source_Archive
ren %%g %date:~-4,4%%date:~-7,2%%date:~-10,2%_%%g
echo Data load ended successfully %date% %time% >> %logfile%
)
实际上%%g
正在选择第二个文件名并将其打印在日志文件中。任何指针都将受到高度赞赏。
谢谢, 猩猩