Search This Blog

Thursday, January 19, 2017

Rename Multiple Files using Excel in Windows

Ever been in the situation where you need to rename a bunch of files without giving them then same name with a number extension? Ever needed to rename a long list of images so they're search engine friendly? Well if the answer is yes, then your in for a real treat. There's a quick and easy solution to renaming files using Microsoft Excel (or any other spreadsheet software) and the windows command prompt.
For this example, I'll be renaming a folder of images so the name replaces spaces with dashes and adds a keyword to the end, making them more SEO friendly.
Here's how to go about doing this...

Step 1 - Generate Your File List

First thing is to get a list of all the files you want to rename. Start by opening the command prompt by clicking Start then typing cmd (in XP, hit run and then type cmd). This will open up the command prompt.
Then we need to change the current directory to the one we want. An easy way of doing this is to open the folder and copy the location. Got the command prompt, type cd and then right-click and hit paste. Hit enter and the directory we're working within will change to the one with all our images in.
image
Now we need to generate the list of images. Type this:
dir /b > _list.txt
This will create a list of all the files in the folder and export them to a new file called _list.txt. You can call this file what you want.

Step 2 :
  The fun starts now. Fire your copy of Microsoft Excel or Google Docs Spreadsheets and paste those file names into the first spreadsheet column.

Step 3:
In the blank adjacent column, add a corresponding Excel function – for instance, use SUBSTITUTE to change specific text in the filenames, use CONCATENATE() with DATE() if you want to add date to the filename, etc.
rename multiple files
*For more complex criteria, you may want to put the file extensions in a separate column by splitting the file name using period (.) as the delimiter.
Step 5: Your source filenames are now in column A while the Destination files are in column B – we will now convert this into a DOS rename command.
In Column C, type the following Excel formula and your command is ready to be executed.
=CONCATENATE(“ren “,A1, ” “, B1)
windows-rename-command
Copy paste the same formula across all cells in column C for which you have corresponding values in Column A or B.
We are almost done. Copy all the values from column C to the clipboard and paste them inside the DOS window or better still, put them inside a new text file and give it a name like rename.bat.
rename-batch-commandExecute and all files that match the criteria are renamed instantly.
And that's it tadaa all renamed.

No comments:

Post a Comment