China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-03 07:50
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How can I delete the NAME text file generated by this batch file? View 668 Replies 1
Original Poster Posted 2007-01-26 21:09 ·  中国 陕西 汉中 电信
初级用户
Credits 136
Posts 49
Joined 2007-01-04 08:28
19-year member
UID 75413
Gender Male
Status Offline
Below is a batch file for renaming files in bulk. I also want to achieve the following functions, please ask an expert for help:
1 Delete the generated NAME text file
2 If I don't know the file type, how can I determine it
3 Long filenames can't be renamed, I don't know how to solve that!

@echo off
setlocal enabledelayedexpansion
set /a num=0
dir *.jpg >>name.txt
for /f "skip=5 tokens=4" %%a in (name.txt) do (
set yum=%%a
set /a num+=1
set num=!num!.jpg
call :start %%a !num!
)
:start
ren %1 %2
goto eof
Floor 2 Posted 2007-01-27 09:57 ·  中国 江苏 南京 电信
初级用户
★★
Credits 138
Posts 50
Joined 2007-01-23 10:59
19-year member
UID 77428
Gender Male
Status Offline
@echo off
setlocal enabledelayedexpansion
set /a num=0
set /p ext=Enter the extension of the files to be batch-renamed (for example: txt):
dir /b *.%ext% >>name.txt
for /f "tokens=*" %%a in (name.txt) do (
set /a num+=1
set num=!num!.%ext%
echo %%a--^>!num!
ren "%%a" "!num!"
)
echo Batch rename completed!
pause>nul
del /f /q name.txt
Forum Jump: