Find knowledge base article(s) by searching for keywords in the title e.g. type linux in the search box below
Find knowledge base article(s) by browsing the subject categories of articles
Technology quick references, cheatsheets, user manuals etc.
Shop Online through ShopifyLite
Tutorials on various IT applications.
Search Title    (UL:0 |SS:f)

Software >> OS >> Windows >> Command Line >> How to rename files matching a pattern



## Example 1 : To move and rename files x_y_z.txt to x.txt
 
on command line:
FOR /F "usebackq tokens=1,2* delims=_" %i in (`DIR /B original\*.TXT`) do move original\%i_%j_%k renamed\%i.txt
 
on batch files:
FOR /F "usebackq tokens=1,2* delims=_" %%i in (`DIR /B original\*.TXT`) do move original\%%i_%%j_%%k renamed\%%i.txt



## Example 2: To rename files a_b.c to a.c

on command line:
FOR /F "usebackq tokens=1,2,3 delims=_." %a in (`DIR /b *_*.*`) do rename %a_%b.%c %a.%c

in batch file:
FOR /F "usebackq tokens=1,2,3 delims=_." %%a in (`DIR /b *_*.*`) do rename %%a_%%b.%%c %%a.%%c








[ © 2008-2021 myfaqbase.com - A property of WPDC Consulting ]