Batch file to modify the file name suffixes

New Text folder, enter the code, change the text suffix .bat

File with the text you want to change in the same folder

Double-click to run

 

 

1. batch delete the file extension

ren *.png* *.png
Remove. "Download"
After running

 

 

2. Batch delete duplicate file extension

ren *.png *.

After running

3. Batch delete n characters before the file name

OFF @echo
setlocal enabledelayedexpansion

:: remove the batch file name before N characters, if there is a folder for each file in the search folder will be modified
set / p format = What suffix filename to change? // you want to change what file suffix 
set / p deletenum = How many characters do you want to delete? // How many beginning you want to delete a character
for / r %% i in (.) Do (
    for / f "delims = "%% A in ( 'the dir / B" %% I \ *.%% the format "2 ^> NUL') do (
        SET" %% ~ T = Na "
        REN" %% I \ %% A "" ! t:! ~% deletenum% %% ~ XA "
    )
)

PAUSE

Runtime

After running

4. batch delete the file name specified character

OFF @echo
Setlocal Enabledelayedexpansion
SET "STR = write here the character you want to delete"
for / F "delims =" %% I in ( 'the dir / B *. *') do (
SET "%% I var =" & REN " %% i "" var:!! % str% = ")
before running

After running

 

Guess you like

Origin www.cnblogs.com/ivychang/p/12399145.html