Dos script to rename files

gbr00435 Posts 1 Registration date Wednesday August 20, 2008 Status Member Last seen August 21, 2008 - Aug 21, 2008 at 11:29 AM
 rajesh kanna - Jun 3, 2014 at 11:50 AM
I would like to know what batch commands I can to to rename files in directory called \\gbr1w001\data_transfer_gb77$

INVPRT_5023949000004_20080818061329_0000979.GB ---> 5023949000004_MSG_IN_20080818061329_0000979.GB

PPRHDR_5000119000006_20080721061424_00000981.GB_m ---> 5000119000006_MSG_IN_20080721061424_00000981.GB_m

SLSRPT_5023949000004_20080721061317_00000978.GB ---> 5023949000004_MSG_IN_20080721061317_00000978.GB

Basically I would like to drop 7 characters at the begining of the file and insert MSG_IN_ after next 14 characters.

Any help on this will be most appreciated.

Thank you

13 responses

for /r %%x in (%1) do ren "%%x" %2

this will rename file recursively :-)

save in a file give 2 arguments from extension and to extension.

ex: file name is test.bat
command : test *.avi *.bmp

it renames all files with extension avi to bmp (in all subfolders :))
Hey Satya,

Thanks for the dos script to rename files.
I was stuck on that, and had to rename a large directory with 5000 files distributed in several subdirectories.

And your script worked just perfect!!!!

hi ,

i am trying to use following command for renaming a1.txt, a2.txt ...aN.txt files to a1-v1.xt ...aN-vN.txt
by running
bathc file run
test *.txt *-v1.txt
contents of batch file
For /r %%x in (%1) do ren "%%x" %2

now my files are getting renamed like a1.txt-v1 which I don't want . I want a1-v1.txt
Please can you tell me the dos command for that.

Thanks in advacne