我想将文件重命名为按日期使用批处理文件。现在我的挑战是,如果文件名存在,它应该附加一个(1)..。(2).(3)在每一个文件的末尾。
ren c:\LogFiles\*.log BackupLog-%date:~-4,4%%date:~-7,2%%date:~-10,2%.log我也想知道是否有可能
如果不能用批处理文件,请协助电源外壳。
发布于 2013-10-02 17:49:27
试试看你的附加问题:
@echo off &setlocal
set "logpath=c:\LogFiles"
for /f "delims=" %%a in ('dir /b /a-d /od "%logpath%\*.log"') do call:doit "%logpath%\%%~a"
goto:eof
:doit
setlocal
set "npre=BackupLog-%date:~-4,4%%date:~-7,2%%date:~-10,2%"
:loop
if defined fcnt (set "nname=%npre% (%fcnt%)%~x1") else set "nname=%npre%%~x1"
set /a cnt+=1
set "fcnt=00%cnt%"
set "fcnt=%fcnt:~-3%"
if exist "%logpath%\%nname%" goto:loop
echo ren "%~1" "%nname%"
ren "%~1" "%nname%"
endlocal
exit /b如果你有更多的问题,请让new questions。
https://stackoverflow.com/questions/19140044
复制相似问题