Delete/modify certain (Chinese characters) strings in file names in batches

problem solved

1. First, batch files (folders) should be placed in the same file directory. like:

2. In this directory, create a new text file and enter the following code, such as:

@echo off
set /p str1= Please enter the file (folder) name string to be replaced (spaces can be replaced): set /p str2= Please enter the replaced file (folder) name string (
if you delete it, press Enter): echo. echo is in operation, please wait
...
for
/f "delims=" %%a in ('dir /s /b ^|sort /+65535') do ( if "%%~nxa" neq "%~nx0" ( set "file=%%a" set "name=%%~na" set "extension=%%~xa" call set "name=%%name:%str1%=%str2%%%" setlocal enabledelayedexpansion ren "!file!" "!name
!!
extension
!
"
2
>
nul
endlocal
)
)
exit

3. Modify the suffix of the text file .txt to .bat.

4. Click Run, input the character string in the file (folder) to be replaced , and the character string to be replaced. (If you want to delete, just press Enter) such as:

 final effect:

Guess you like

Origin blog.csdn.net/doumaidexiaozhi/article/details/127096469