Page 1 of 1

Rename file extension with another file extension

Posted: 28 Mar 2011 20:49
by ayya_freesia
Hye everyone..Such a nice forum..I am very new to using MS-DOS as a scripting language so please forgive my (hopefully) easy question. What I am trying to do is to create a batch file command to find all the file with .XML extension and rename it to .tmp extension. After this create a second batch file to rename from .tmp back to .xml extension. Can anyone help me on this matter.

:( :?

Thank you so much.

Re: Rename file extension with another file extension

Posted: 28 Mar 2011 23:58
by phillid
Welcome to the forum!

To rename all .XML files to .tmp, simply use wildcards:

Code: Select all

@echo off
ren *.XML *.tmp


And to rename the .tmp files back to .XML, just do the reverse

Code: Select all

@echo off
ren *.tmp *.XML


Please note that this will only rename files in the folder path in %CD%

Hope this helps!! :D

phillid