Showing posts with label Batch file. Show all posts
Showing posts with label Batch file. Show all posts

Batch file to replace file extensions

Previously I have written how to change extensions of several files by using the command prompt in just a few steps. Now we will see another method for that purpose.
image

Suppose you want to change all files in a folder with bmp extensions to have them rar extensions instead.

Open Notepad and write:

ren *.bmp *.rar

save this file as renamer.bat

*.bmp is your default extension, *.rar is your preferred extension.
This bat file will rename all *.bmp extension files in the folder to *.rar extension files.

Shortcut to Launch Multiple Programs

We may have hundreds of programs installed on our system but we only use couple of them on occasional basis (that is why I prefer portable programs) and some of these installed programs come preconfigured to load on windows startup. I suggest you clean these programs from windows startup (only leaving the programs that you are sure you will need every time you log on windows) by either using MSConfig or using a specialized program like Autoruns from SysInternals.
After cleaning the start up programs you can create a batch file to start all your favorites ones with just one click. And here is how to do that:

Open Notepad (Start Menu -> Accessories -> Notepad):

Get the paths for the programs you want to start. The easiest way to do this is to right-click on each of the existing shortcuts, choose the Properties option, and then copy the Target path.

Enter the paths for each of the programs into Notepad, one per line. Be sure to write

start ""

at the beginning of each line, and put a space after it to separate it from the application path. If the path of your application has a space in it, you'll need to surround the entire path with quotes.

Save it as a .bat file by manually entering in the extension at the end of the file name.

In the end you should have something like this:

start "" "C:\Program Files\Opera\Opera.exe"

start "" "C:\Program Files\Windows Live\Messenger\msnmsgr.exe"

start "" "C:\Program Files\FeedDemon\FeedDemon.exe"

With this method your Windows will load a little much faster depending on your hardware.

How to quickly replace the file extensions of several files

Sometimes it may be necessary to change the extensions of several files to allow compatibility with a particular program. For example you may need to change the extension of all the asp files in a folder to htm. If there are plenty of files in your folder it would be a very tedious work to do. But with a little command magic you can do the job in just a few steps.
For this example we will change all the files with an *.asp extension to a *.htm files.
If you want to keep the original files just in case use the below command at the CMD prompt or within a batch file:

xcopy *.asp *.htm
This would create a copy of all files with .asp extension and rename them to .htm, while keeping the original files.

If you simply wish to rename the extensions without keeping the original file you can just replace xcopy command to rename as below example.
rename *.asp *.htm

What if your files do not have any extension at all (there are programs that come in archives with text files that do not have extensons). For example if you want to add txt extension to all files in a folder open command prompt (win + R / cmd), navigate to your folder than enter the below command.

ren * *.jpg