我试图重命名所有.txt.1。文件到.txt,还可以更改文件名的最后两个字符。执行程序时,即使文件被重命名,我收到错误存在重复的文件名,或者找不到该文件。
@Echo off
pushd &source#
set cnt=0
setlocal enabledelayedexpansion
for %%A in (*.pgp.1) do (set /a cnt+=1)
echo(
echo File count = !cnt!
echo(
if !cnt! gtr 0 (
for %%g in (*.txt.1) do (
set string=%%g
set extension=!string:~40,4!
set "file_name=!string:~0,38!"
set "last_two=!string:~38,2!"
set /a add_millisec=!last_two!+1
set add_millisec=00!add_millisec!
set add_millisec=!add_millisec:~-2!
set exception=10
if !last_two! equ 99 (
set final_string=!file_name!!exception!!extension!
ren *.txt.1 !final_string!
) else (
set final_string=!file_name!!add_millisec!!extension!
ren *.txt.1 !final_string!
)
echo !final_string!
)
) else (
echo(
echo No files to rename
echo(
)
我错了,有人可以查一下..