中国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-09-23 13:29
47,812 topics / 349,917 posts / today 0 new / 48,273 members
DOS批处理 & 脚本技术(批处理室) » [Help]Newcomer's Inquiry - Improvement of "Batch Rename Suffix.bat"
Printable Version  1,981 / 6
Floor1 lujice Posted 2011-01-21 14:42
新手上路 Posts 13 Credits 12
The code is as follows:

@echo off
:0
cls
echo.
echo. ╭────────╮
echo. ╭────┤ Usage Instructions ├────╮
echo. │ ╰────────╯ │
echo. │ │
echo. │ 1、The purpose of this tool is - batch modify files with specified suffixes in the specified directory to other specified suffixes. │
echo. │ │
echo. │ 2、Please press Enter after each input! │
echo. │ │
echo. │ 3、Note - only enter the suffix, do not enter the "." before the suffix │
echo. │ │
echo. │ 4、If there are spaces and special characters in the folder path, please type it in manually, do not drag and drop! │
echo. │ │
echo. ╰──────────────────╯
echo.&echo Please enter the path of the folder, or drag and drop the folder to this window
set LJ=
set /p LJ=
if /i "%LJ%"=="" goto 0
echo.&echo Please enter the original suffix name:
set q=
set /p q=
if /i "%q%"=="" goto 0
echo.&echo Please enter the new suffix name:
set h=
set /p h=
if /i "%h%"=="" goto 0
cd %LJ%
REN *.%q% *.%h%
echo.&echo. Suffix names have been batch modified successfully!
echo.&echo. Please open the folder and take a look!
start %LJ%
pause
goto 0

This batch processing is my original work and is basically successful.

The questions are -
1、When there are spaces and special characters in the folder path, how to support drag and drop?
2、If you want to process all subdirectories under the folder at the same time, how to write it?
3、In order to avoid being detected, I also want to go further: "While batch modifying the suffix name, batch modify the file name".
That is - add a number 1 between the first character and the second character of the file name.
How to write this?
4、For example, I want to change all "*.cpl" files in "C:\WINDOWS\system32" to "all suffix names uniformly changed to bbb, and a number 1 is added between the first character and the second character of the file name".
In this case, how to write the batch processing to restore the original file name and suffix?

Looking forward to the expert's answer!

Thanks in advance!!!

Kowtow......
Floor2 lujice Posted 2011-01-21 14:46
新手上路 Posts 13 Credits 12
This batch script, if used to "prohibit using the Control Panel", is不知 how much better than the codes spread online......

Hehe......
Floor3 Hanyeguxing Posted 2011-01-21 16:35
银牌会员 Posts 897 Credits 1,039 From 在地狱中仰望天堂
Changing the CPL extension and prohibiting the use of the Control Panel are two different things.

The sensitive characters that should not be processed still cannot be processed: support drag-and-drop, support double-click, support filtering, support mixing of files and directories during drag-and-drop


[ Last edited by Hanyeguxing on 2011-1-21 at 17:00 ]
Floor4 lujice Posted 2011-01-21 16:43
新手上路 Posts 13 Credits 12
Originally posted by Hanyeguxing at 2011-1-21 16:35:
Changing the .cpl extension and prohibiting the use of the Control Panel are two different things
The sensitive characters that cannot be processed still cannot be processed:
Floor5 Hanyeguxing Posted 2011-01-21 16:54
银牌会员 Posts 897 Credits 1,039 From 在地狱中仰望天堂
1, Why pack a bat into an exe for no reason?
2, For the sample I wrote for you, do you still need to copy it exactly?

[ Last edited by Hanyeguxing on 2011-1-21 at 17:04 ]
Floor6 xyz1234111 Posted 2011-01-21 20:13
初级用户 Posts 32 Credits 32
Learned.

Let me say an off-topic thing!

Brother Hanye, can this effect of bundling love and hate in the picture be done with batch processing? If it can, can you show me the code?
Floor7 lujice Posted 2011-01-22 15:51
新手上路 Posts 13 Credits 12
Strange!
Why does creating a recycle bin support spaces and special characters again?


@echo off
:0
cls
echo.
echo. ╭────────╮
echo. ╭────┤ Usage Instructions ├────╮
echo. │ ╰────────╯ │
echo. │ │
echo. │ 1、The purpose of this tool is - to create a recycle bin in the specified directory │
echo. │ inside. │
echo. │ │
echo. │ 2、Please press Enter after each input! │
echo. │ │
echo. │ 3、Supports folder names and paths containing │
echo. │ spaces and special characters! │
echo. │ │
echo. │ 3、When manually entering the folder name and path, and the recycle bin name, please add English double quotes before and after - " │
echo. │ │
echo. ╰──────────────────╯
echo.&echo Please enter the folder path, or drag and drop the folder into this window
set mulu=
set /p mulu=
echo.&echo Please enter the name of the recycle bin:
set /p minzi=
md %mulu%\%minzi%>nul 2>nul
attrib +s +h %mulu%\%minzi%>nul 2>nul
(echo [.ShellClassInfo]
echo CLSID={645FF040-5081-101B-9F08-00AA002F954E})>%mulu%\%minzi%\desktop.ini
attrib +s +h %mulu%\%minzi%\desktop.ini
echo.&echo. Recycle bin created successfully!
echo.&echo. Go and open it manually!
echo.
pause
goto 0
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023