Rename file extension with another file extension

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ayya_freesia
Posts: 1
Joined: 28 Mar 2011 20:07

Rename file extension with another file extension

#1 Post by ayya_freesia » 28 Mar 2011 20:49

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.

phillid
Posts: 109
Joined: 03 Apr 2010 20:27
Location: Wellington, New Zealand
Contact:

Re: Rename file extension with another file extension

#2 Post by phillid » 28 Mar 2011 23:58

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

Post Reply