Pages

Wednesday, February 24, 2010

batch file part - 5 (examples)

How to quickly replace the file extensions of several files.


Issue:

How to quickly replace the file extensions of several files.

Reasoning:

It may be necessary to rename several files to allow compatibility with another program. A good example where this could be used is renaming an ASP file to an HTM or HTML file.

Solution:

Use the below command at the MS-DOS prompt or within a batch file.

xcopy *.shn *.wav

This would rename all files with .shn to .wav, while keeping the original files.

If you simply wish to rename the extensions without keeping the original file you can also use a command similar to the below example.

rename *.shn *.wav

See our ren and rename command and/or xcopy command pages for additional information about these commands.

No comments: