Web Analytics

Windows Guides Feed

Sooner or later you may face the problem of how to change the names of a large group of files. A case in point is a situation wherein you have a group of files – perhaps a group of episodes from a TV series that have been named correctly, but in a non-standard format – and you need to change those file names to conform with an accepted standard, for example, in the form of SXXEYY where XX is the season number and YY is the episode number, followed by the file type suffix. This code is often referred to as the “Sexxyy” standard.

The Files:

The original files may come from a variety of sources, many of them ad hoc and without regard for the standards, or perhaps named for a different standard (there are several to choose from).

Taking a download from the Internet, you might get a list of files that look like this:

BSG [1×01] 33 FASM HR HDTV.wmv
BSG [1×02] Water FASM HR HDTV.wmv
BSG [1×03] Bastille Day FASM HR HDTV.wmv
BSG [1×04] Act Of Contrition FASM HR HDTV.wmv
BSG [1×05] You Can’t Go Home Again FASM HR HDTV.wmv
BSG [1×06] Litmus FASM HR HDTV.wmv
BSG [1×07] Six Degrees Of Separation FASM HR HDTV.wmv
BSG [1×08] Flesh And Bone FASM HR HDTV.wmv
BSG [1×09] Tigh Me Up, Tigh Me Down FASM HR HDTV.wmv
BSG [1×10] The Hand Of God FASM HR HDTV.wmv
BSG [1×11] Colonial Day FASM HR HDTV.wmv
BSG [1×12] Kobol’s Last Gleaming – Part 1 FASM HR HDTV.wmv
BSG [1×13] Kobol’s Last Gleaming – Part 2 FASM HR HDTV.wmv

The next step is to change the names to conform with the standard.

The Commands:

Most users will be familiar with the Windows Explorer program and its ability to change single file names and some users will be aware of the ability to highlight a range of files and right-mouse-click to rename the selected files to a single “base name” – the result being a list that looks like filename.txt, filename (1).txt, filename (2).txt etc. but neither of these can be used in a batch file nor do they give us the kind of control we need over the resulting file names.

Fortunately, Windows continues to provide a command line interface — the “command prompt” as it is known in Windows 7.

Changing the name of a file can be done with several commands from the command line – “copy”, “rename” and the “move” command come to mind. Syntax for the move command is simply:

move “old file name.xxx” “newfilename.xxx”

Editing each file name individually is both error prone, and time-consuming. It’s much faster (especially if you plan to do more bulk changes in the future) to create a batchfile — better still if you create a batch file creator that will do the job for you.

The Process:

Our first task is to create a list of the original file names. Open a command prompt and “cd” into the directory containing the video files then type the command “dir /B > C:\list1.txt”. This command will create a “bare” list of filenames like the list shown above and put that list into a file in the root directory of the C: drive called list1.txt.

NOTE: The file name and destination of list1.txt doesn’t matter so long as you can find it again.

Use excel to open C:\list1.txt and this will give you a worksheet with a list of the filenames in column A. Scan through the list to make sure the episodes are in the right order and that none are missing – if there are any missing episodes insert a blank cell in the list for each. Remove any files that are not videos in the series. The final list should be a complete list of all the episodes of one season.

Next, start the series of new SEXXYY episode file names for season 01 by entering S01E01 in column B1. Next, hover around the bottom right corner of cell B1 until the cursor turns into a thin dark cross-hair and drag the cursor down till it matches the bottom of column “A” creating consecutively numbered cells — S01E01, S01E02, S01E03 etc.

The third column is where the magic happens. It’s an excel formula:

=CONCATENATE(“move “””,A1,””””,” “,””,” “,””””,B1,”.avi”,””””)

that says “combine the word “move” with whatever is the the first column (the existing file name) and whatever is in the second column (the sexxyy file name) and print the whole thing out like a stack of DOS command lines”.


A batch file is simply a file containing proper commands like the move command shown above – to execute the batchfile it’s best to give the file a “.bat” suffix as in “do_move.bat” then type the name of the batchfile at the command prompt. All that’s required is the name of the files to be moved, and the name of the file it is to be moved to. Where possible, it’s best to copy and paste the names from an existing list, or generate a sequence of names from a program like excel and then let the excel create the command lines.

Copy the list of commands in column “C” and paste them into a blank notepad page — using the notepad “save as” command, navigate to the folder containing the raw files and save the notepad page as a batch file with a name like “doShow.bat” – where “Show” is a short title for the TV Series.

NOTE: This version assumes all episodes are in the “.avi” format — if all episodes are in another format – like .mpg or .mkv , then replace “.avi” in the formula with the appropriate suffix. If your episodes are in different formats, use Batchfile2 below.

Using either the command prompt, or Windows explorer, navigate once again to the folder containing your target files and type or double click the command “doShow.bat” – list the files once again and they should now be the new names.


A fancier version of this spreadsheet requires an additional column to hold the file extension information.

Cells in C are  =right(A1,4)

This says “Take the last 4 characters from whatever is in cell A1 (our file names).  If the results don’t look right, check the contents of A1 for trailing blank spaces.

The last cell makes the command lines.

Cells in D are =IF((LEN(A1)>0),CONCATENATE(“move “””,A1,””””,” “,””,” “,””””,B1,C1,””””),”rem”)

Its purpose is 1) to replace blank lines with the word “rem” to avoid any stray characters fouling the script and 2) automatically add the right extension to the new file names. NOTE: this script is only good for 3-character extensions.

Here is what a final worksheet might look like:

The next step is to copy the cells in column D and paste them into a blank notepad page:

Save the batch file in the same folder as the original video files with a name like “doBSG.bat”.

Finally, use windows explorer or your command prompt to navigate to the target folder and execute (double-click) our batch file “doBSG.bat”.  Refresh the folder view and you should see the new file names.

About Deck Hazen

A computer user since 1976, Deck enjoys testing new software and reconfiguring his equipment to squeeze the most out of it. "Computing has come a long way since those early days" Deck recalls "I get a real kick out of watching the industry grow - getting paid to write about it is just icing on the cake!"

Free PC tips by email

Search Windows Guides


4 thoughts on “Mass Convert File Names in Windows with a Batch File [How To]”

  1. Jayalaba says:

    You are the Man…

  2. PeterN says:

    Thanks, I was wondering how to convert Windows filenames to Linux web compliant names with spaces converted to underscore, and cases converted to lower case. I wrote Delphi code to do a text replacement but not a lower case conversion, that was 15 years ago and I’m too rusty to re-learn so hopefully your step by step process with fallback will work. Thanks Peter.

  3. stregobor says:

    Or do it by Adobe Bridge :)

  4. wahid haq says:

    I suggest everyone to try KrojamSoft BatchRenameFiles program. It’s really work for me.

Comments are closed.

Computer tips in your inbox
Sign up for the Windows Guides newsletter to get PC tips and access to free Windows books (More details)

Enter your email address:

Popular Guides

See which sites have been visited on your PC (even if private browsing mode is used)

Create a Windows 7 System Repair Disc

Best Free Anti-malware

Hibernate vs. Sleep vs. Shut-Down

i3, i5, and i7; Dual, Quad, Hexa Core Processors. How to they Differ?

Intel's Ivy Bridge Processor: new Features

Submit Your Tip
Submit your computer tip to us; receive full credit for all published tips

Windows Guides on Facebook