Thursday, March 16, 2006

Batch Renaming File Extensions

Lets say you have a bunch of files in a specific directory and they are all of one file type and you want to switch them all over to another file type but it would be a pain to rename them manually. You can create your very own batch script to do this. Open notepad and create a file. Click file save as and type in rename.bat . Be sure to add the .bat at the end otherwise it will save the file as a .txt Now type in the following in notepad:

cd..
cd..
cd..
cd..
cd..
cd documents and settings
cd yourname
cd my documents
cd file folder
rename *.html *.php
pause


Here's what is does now. If you start the program in some crazy directory cd.. goes down one directory. That should be enough (cd..). Cd documents and settings goes into the folder you wish to go into, you can cd into any directory you want, this is just for an example. Once you cd into the directory of your choice the (rename *.html *.php) command renames all files of the .html file extension to the .php file extension. You can rename any file extension to any file extension you want, just change the .html and .php . Finally the pause puts a pause in the program that says: press any key to continue... This allows you to see if everything went successfully. Otherwise you can take it out and it will run the program quicker then the blink of an eye and you won't really notice it.

2 Comments:

At Saturday, March 18, 2006 7:25:00 AM, Blogger jase said...

i usually put this at the beginning of my batch files, that way i know exactly where i'm starting. even with all the cd..'s you might not end up where you think you will:

c:
cd\

now you know you're in the root of your c drive.

 
At Friday, November 20, 2009 11:59:00 AM, Anonymous Anonymous said...

Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!

 

Post a Comment

<< Home