中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-02 17:57
48,038 topics / 350,123 posts / today 1 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » Please provide more specific information about the batch file name modification requirements, such as what kind of naming rules need to be followed for batch modification, for example, whether it is to add a prefix, suffix, replace certain characters, etc. Then I can write the corresponding script for you.
Printable Version  1,464 / 11
Floor1 fjzzgxwb Posted 2006-12-01 09:12
新手上路 Posts 6 Credits 13
Thanks, for example: (A is a constant, B is a variable)

A123.txt After renaming --------> 123.txt

A456.txt After renaming ---------> 456.txt

A999.txt After renaming ---------> 999.txt

ps: (To put it simply, that is, remove the constant A, :)

Also need to be able to scan the entire disk.

Thanks :P:P~~~
Floor2 namejm Posted 2006-12-01 09:27
荣誉版主 Posts 1,737 Credits 5,226 From 成都
If constant A is of fixed length, you can consider removing A through character truncation operations; if the length is not fixed, the format of set var=!str1:A=! can be used reluctantly, provided that: in the same file name, the string A does not overlap with the rest.
Floor3 fjzzgxwb Posted 2006-12-01 09:40
新手上路 Posts 6 Credits 13
Um, the moderator is very enthusiastic, thank you.
Here, for A, I need to use strings. The following is for example [www.163.com]
Can the moderator help write a batch script?
Floor4 namejm Posted 2006-12-01 11:14
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Here are the translations:

Here are two demonstration codes:





The content of test.txt is:

Floor5 a9319751 Posted 2006-12-02 06:45
中级用户 Posts 170 Credits 439
TV drama renamed, not very perfect
@echo off
setlocal enabledelayedexpansion
echo The default renamed file name is 01.rm
pause
set newname=01.rm
:set /p oldname=Please enter the old file name:
:set /p newname=Please enter the new file name:
set /p num=Please enter the total number of episodes:
for /f "tokens=1,2 delims=." %%i in ("%newname%") do (
set newname1=%%i
set newname2=%%j
)
if "%newname1:~0,1%"=="0" set newname1=%newname1:~1%
:loop
for %%i in (*.*) do (echo %%i |find "0%newname1%" && move %%i 0%newname1%.%newname2%)
if "%newname1%"=="%num%" goto :eof
set /a newname1=%newname1%+1
goto loop
Floor6 a9319751 Posted 2006-12-02 07:31
中级用户 Posts 170 Credits 439
test

[ Last edited by a9319751 on 2006-12-5 at 04:41 AM ]
Floor7 fjzzgxwb Posted 2006-12-02 17:28
新手上路 Posts 6 Credits 13
Thanks to the moderator and the friend above for your enthusiastic help, and thank you all for your attention.

Well, I registered on this forum and immediately posted a help-seeking post. I'm really a bit embarrassed. Actually, I really want this batch processing to change movie names... Hehe~~ Changing each name one by one is a lot of work, and I don't know batch processing. Helpless~

I tried it. The moderator's batch processing can rename, but it's still limited to the names we listed...

What if we don't know in advance how many such ones with fixed symbols [www.163.com] are in our computer?

Then it's not convenient.

The batch processing of the friend above is still not enough.

Please help improve it if you know how. I'm very grateful...
Floor8 namejm Posted 2006-12-02 20:08
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Then you need to list all your conditions. Just saying replace constant A, but not giving all possible situations, then I can only give the demo code.
Floor9 fjzzgxwb Posted 2006-12-02 23:12
新手上路 Posts 6 Credits 13
The moderator is here so early, heh. I'm sorry, I didn't make the problem clear.

The effect I want is: After running the batch file, it will first let the user enter the defined constant A[www.163.com],

(Because some movies are not just under one address, so it will be different), then use the batch file to remove the amount with

[www.163.com], and there should be no overwrite prompt phenomenon (if it can more clearly show how many file names we have actually changed this time, generate a ren.txt under the C drive to record it, which is the best), and also filter all files on my computer, such as C, D, E, F drives...

That's the situation. Thank you again!
Floor10 fjzzgxwb Posted 2006-12-04 01:33
新手上路 Posts 6 Credits 13
I'm sorry, I need this batch script urgently. Please help if you know how, thank you
Floor11 a9319751 Posted 2006-12-04 07:55
中级用户 Posts 170 Credits 439
Renaming Files.bat

@echo off
set /p oldname=Please enter the old file name:
set /p newname=Please enter the new file name:
setlocal enabledelayedexpansion
dir /b . >list.txt
for /f "tokens=1 delims=1" %%i in ("%oldname%") do set name=%%i
if "%name:~-1%"=="0" set name=%name:~0,-1%
if "%name:~-1%"=="0" set name=%name:~0,-1%
if "%name:~-1%"==" " set name=%name:~0,-1%
if "%name:~-1%"==" " set name=%name:~0,-1%
for /f "delims=" %%i in (list.txt) do (
set var=%%i
set var=!var:%name%=!
ren %%i !var!
)
dir /b . >list.txt
for /f "tokens=1,2 delims=1" %%i in ("%oldname%") do set name=%%j
for /f "delims=" %%i in (list.txt) do (
set var=%%i
set var=!var:%name%=!
ren %%i !var!
)
dir /b . >list.txt
for /f "tokens=1,2 delims=." %%i in ("%newname%") do set name=%%j
for /f "delims=" %%i in (list.txt) do echo %%i |find "." || ren %%i %%i.%name%
del list.txt
del %0

Generating Files.bat
for /f %%i in (listfile.txt) do copy listfile.txt %%i

listfile.txt
[YYSoR]Typhoon in That Summer 01. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 02. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 03. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 04. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 05. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 06. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 07. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 08. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 09. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 10. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 11. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 12. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 13. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 14. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 15. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 16. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 17. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 18. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 19. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 20. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 21. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 22. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 23. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 24. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 25. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 26. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 27. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 28. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 29. Mandarin Chinese Subtitles.d-vb.rmvb
[YYSoR]Typhoon in That Summer 30. Mandarin Chinese Subtitles.d-vb.rmvb

When using, place "Renaming Files.bat" in the folder of the movies to be renamed and run it. Please back up your important files before use
Floor12 arjay Posted 2006-12-04 22:37
新手上路 Posts 5 Credits 9
That's amazing, thank you.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023