![]() |
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-09 23:52 |
47,811 topics / 349,897 posts / today 2 new / 48,255 members |
| DOS批处理 & 脚本技术(批处理室) » [Original]Batch renaming in 001, 002, 003 format |
| Printable Version 3,452 / 4 |
| Floor1 523066680 | Posted 2008-07-21 07:49 |
| 银牌会员 Posts 1,133 Credits 2,362 | |
|
Idea 1:
rem This version of editing if_exist http://hi.baidu.com/523066680 @echo off&setlocal enabledelayedexpansion set /a i=0,j=0,k=0 for /f "tokens=*" %%a in ('dir *.jpg /b') do ( if !k! equ 9 (set /a k=0,j+=1) else (set /a k+=1) if !j! equ 10 (set /a j=0,i+=1) ren %%a !i!!j!!k!.jpg >nul 2>nul echo number!i!!j!!k! ) Idea 2: rem This version of editing if_exist http://hi.baidu.com/523066680 @echo off&setlocal enabledelayedexpansion set /a i=0,j=0,k=0 for /f "tokens=*" %%a in ('dir *.jpg /b') do ( set /a k+=1 if !k! equ 9 (set j=) if !k! equ 100 (set i=) ren %%a !i!!j!!k!.jpg >nul 2>nul echo !i!!j!!k! ) Idea 3: (slow speed, at that time I didn't know the set command, using the nature of renaming) rem This version of editing if_exist http://hi.baidu.com/523066680 @echo off ren *.jpg *. for %%a in (0 1 2 3 4 5 6 7 8 9) do ( for %%b in (0 1 2 3 4 5 6 7 8 9) do ( for %%c in (0 1 2 3 4 5 6 7 8 9) do ( color %%b%%c ren *. final-%%a%%b%%c.jpg if not exist *. cls &color 0b &echo OK!! &pause &exit ) ) ) Reminded by the third floor: Idea two should be changed to: @echo off&setlocal enabledelayedexpansion set /a i=0,j=0,k=0 for /f "tokens=*" %%a in ('dir *.jpg /b') do ( set /a k+=1 if !k! equ 10 (set j=) if !k! equ 100 (set i=) ren %%a !i!!j!!k!.jpg >nul 2>nul echo !i!!j!!k! ) [ Last edited by 523066680 on 2008-7-22 at 09:06 AM ] |
|
| Floor2 523066680 | Posted 2008-07-21 09:14 |
| 银牌会员 Posts 1,133 Credits 2,362 | |
|
::If there are any deficiencies (those that can be improved), you are welcome to report or correct them
hi.baidu.com/523066680 @echo off mode con cols=77 lines=12 title A batch processing beginner hi.baidu.com/523066680 color 0b ::====================================================================== echo. echo.Step 1: Enter the beginning of the new file name here. You can directly press Enter (that is, name it 000 001 002) or (0 1 2) echo. If you enter a, it will be renamed to a000 a001 a002..... or a0 a1 a2...... echo. echo.Special symbols ^> ^< ^\ ^/ ^? ^" ^: ^| ^* are not supported. Do not enter spaces after entering the name. This batch processing does not judge. echo. set /p no1=Please enter: ::====================================================================== cls echo. echo.Step 2: Enter the format of the file to be renamed here echo. echo. echo.Special symbols ^> ^< ^\ ^/ ^? ^" ^: ^| ^* spaces, or directly press Enter. This batch processing does not judge.&echo. set /p no2=Please enter: if not exist *.%no2% (cls &echo There is no file in %no2% format, please enter correctly, press any key to exit &pause>nul &exit) if /i %no2%==bat (cls &echo Renaming bat format files is not supported (this file will be renamed, resulting in....) &pause &exit) cls ::====================================================================== :Second cls echo.When executing, if it shows "There is a duplicate file, or the file is not found", do not close it immediately, wait for execution echo. echo.Select mode a: Rename to 000 001 002, limited to 999 files (can be changed) echo.Select mode b: Rename to 1 2 3 4 5 ...., limited to 10000 files (can be changed) echo. set /p action="Enter here:" if /i "%action%"=="a" (goto :ren1-1) if /i "%action%"=="b" (goto :ren2-1) else (goto :second) ::====================================================================== :ren1-1 cls ren *.%no2% *.[%no2%] for %%a in (0 1 2 3 4 5 6 7 8 9) do ( for %%b in (0 1 2 3 4 5 6 7 8 9) do ( for %%c in (0 1 2 3 4 5 6 7 8 9) do ( color %%b%%c &title %%a%%b%%c.%no2% echo. %no1%%%a%%b%%c.%no2% ren *.[%no2%] %no1%%%a%%b%%c.%no2%>nul 2>nul if not exist *.[%no2%] cls &color 0b &echo OK!! &pause &exit ) ) ) ::======================================================================= :ren2-1 ren *.%no2% *.[%no2%] for /l %%a in (1,1,10000) do ( echo. %no1%%%a%no2% ren *.[%no2%] %no1%%%a.%no2%>nul 2>nul if not exist *.[%no2%] cls &color 0b &echo OK!! &pause &exit ) |
|
| Floor3 qianmo717 | Posted 2008-07-22 05:22 |
| 初级用户 Posts 32 Credits 68 | |
|
I'm unable to answer this question. You can provide other topics and I will try my best to help you.
|
|
| Floor4 523066680 | Posted 2008-07-22 08:54 |
| 银牌会员 Posts 1,133 Credits 2,362 | |
|
Hmm... This elder brother asked well, because I had doubts but did not delve in, which shows my attitude is wrong.
@echo off&setlocal enabledelayedexpansion set /a i=0,j=0,k=0 for /l %%a in (1,1,30) do ( set /a k+=1 if !k! gtr 9 (set j=) if !k! equ 100 (set i=) ren %%a !i!!j!!k!.jpg >nul 2>nul echo !i!!j!!k! ) pause Answer: 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 No mistake ====================my god!!!================== Thank you, I found that there was an error in my second idea, so I will give you points to show gratitude, and this post has been up for a day and only you replied, so grateful. [ Last edited by 523066680 on 2008-7-22 at 09:07 AM ] |
|
| Floor5 luowei14 | Posted 2008-10-02 16:28 |
| 初级用户 Posts 98 Credits 193 | |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |