Sie sind auf Seite 1von 11

How to Batch Rename Multiple Files in Windows

Got a bunch of files you want to rename, but dont want to go through them each one by one?
Windows provides more ways to do this than you may realize.
You can easily rename one or more files just with Windows Explorer, but you can do even more
with the Command Prompt or PowerShell. Add in third-party renaming utilities, and the
possibilities are endless. Lets take a look at each option and how it works.

Rename Multiple Files in Windows Explorer


Windows Explorer (known as File Explorer in Windows 10) is surprisingly powerful. You
probably know how to rename a single file, but lets start with the basics, since the advanced
tricks build off them.
If youre using your mouse, you have no less than three ways to select a files name and
rename it. You can:

Click to select the file and then click the Rename button on the Home menu.

Click to select file and then click the name of the selected file.

Right-click the file and then select Rename on the context menu.

And if you prefer sticking with your keyboard, you can just use your arrow keys (or start typing
the file name) to select a file and then hit F2 to select the file name.
Once youve got the file name selectedand youll notice only the file name itself is selected,
not the extensionyou can type a new file name.
When youre done typing the file name, you can press Enter (or just click somewhere else) to
save the new name.
Heres where things get interesting: you can also hit the Tab key to automatically select the next
file name in the folder so that you can immediately begin typing a new name for it. Keep hitting
Tab and typing names this way and you can easily rename all the files in a folder if youre so
inclined.
If youre renaming a bunch of files in the same folder and those files dont need completely
different names from one another, Windows provides an easier way to rename those files in
batch. Start by selecting a bunch of filesyou can hold down the Ctrl key to select multiple files
at once, or Shift to select a range of files. When youve got the files selected, use one of the
rename commandsthe button on the Home menu, the command on the context menu, or just

press F2. Youll see that all the files remain selected, but the first one in the group gets its name
highlighted so you can type a new name.

Type a new name for the file and then hit Enter or click somewhere else in the window. All the
selected files are renamed using the name you just typed, and are appended with a number in
parentheses to differentiate them.

Rename Multiple Files from the Command Prompt


If you need more power than that, you can use the rename or ren command in a Command
Prompt window to one or more files. The command accepts wildcard characters like * and ? for
matching multiple files, which can be helpful if you only want to rename a certain selection of
files in a folder full of many.
The quickest way to open a Command Prompt window at your desired location is to first open
the folder in File Explorer. From the File menu, point to Open command prompt, and then
select Open command prompt.

To rename a single file, you can use the following command syntax:

ren "current_filename.ext" "new_filename.ext"

The quotes are important if your file names contain any spaces. If they dont, you wont need the
quotes. So, for example, to rename a file from wordfile (1).docx to my word file (01).docx you
would use the following command:

ren

"wordfile (1).docx" "my word file (01).docx"

Since the ren command can address extensions, you can also use it to change the extensions
of multiple files at once. Say, for example, you had a selection of .txt files that you wanted to
turn into .html files. You could use the following command along with the * wildcard (which
basically tells Windows that text of any length should be considered a match):
ren *.txt *.html

And while were on the subject of wildcards, you can also do some interesting things with the ?
wildcard, which is used to stand in for any single character. Say, for example, you had a bunch
of .html files that you wanted to turn into .htm files instead. You could use the following
command to make the change:

ren *.html *.???

This tells Windows to rename all files with the .html extension to use the same file name and
same first three letters only of the file extension, which ends up cutting the l off of all the
extensions in the folder.

RELATED ARTICLE

How to Write a Batch Script on Windows


And this only begins to address the kinds of command line wizardy you can get into if you want
to build more complicated commandsor even batch scriptsby weaving other commands and
conditionals into things. If youre interested, the folks over at the Lagmonster forums have an
excellent writeup on the subject.

Rename Multiple Files with PowerShell


PowerShell offers even more flexibility for renaming files in a command-line environment. Using
PowerShell, you can pipe the output of one commandknown as a commandlet in
PowerShell termsto another command, just like you can on Linux and other UNIX-like
systems. The two important commands youll need are Dir, which lists the files in the current
directory, and Rename-Item, which renames an item (a file, in this case). Pipe the output of Dir
to Rename-Item and youre in business.

The quickest way to open a PowerShell window at your desired location is to first open the
folder in File Explorer. From the File menu, point to Open Windows PowerShell, and then
select Open Windows Powershell.

First, lets look at renaming a single file. For that, you would use the following syntax:

rename-item

"current_filename.ext" "new_filename.ext"

So, for example, to rename a file from wordfile.docx to My Word File.docx you would use the
following commandlet:

rename-item "wordfile.docx" "My Word File.docx"

Easy enough. But the real power in PowerShell comes from the ability to pipe commandlets
together and some of the conditional switches supported by the rename-item commandlet. Say,
for example, we had a bunch of files named wordfile (1).docx, wordfile (2).docx, and so on.
Say we wanted to replace the space in those file names with an underscore so that the file
names contain no spaces. We could use the following commandlet:

dir | rename-item -NewName {$_.name -replace " ","_"}

The dir part of that commandlet lists all the files in the folder and pipes them (thats the |
symbol) to the rename-item commandlet. The $_.name part stands in for each of the files
getting piped. The -replace switch indicates that a replacement is going to happen. The rest of
the commandlet just signifies that any space ( " " ) should be replaced by an underscore
( "_" ).
And now, our files look the way we want.

RELATED ARTICLE

Geek School: Learn How to Automate Windows with PowerShell


As you might expect, PowerShell offers tremendous power when it comes to naming your files
and were only scratching the surface here. For example, the rename-itemcommandlet also
offers features like a -recurse switch that can apply the commandlet to files in a folder and all
folders nested inside that folder, a -force switch that can force renaming for files that are
locked or otherwise unavailable, and even a -whatif switch that describes what would happen
if the commandlet was executed (without actually executing it). And, of course, you can also
build more complicated commandlet structures that even include IF/THEN logic. You can learn
more about PowerShell in general from our Geek School guide, and learn more about
the rename-item commandlet from Microsofts TechNet Library.

Rename Multiple Files Using a Third Party App

RELATED ARTICLE

Bulk Rename Tool is a Lightweight but Powerful File Renaming Tool


If you need a powerful way to rename multiple files at once and youre just not up for mastering
the Command Prompt or PowerShell commands, you can always turn to a third-party utility.
There are countless renaming apps our thereand many of them are goodbut we have two
clear favorites: Bulk Rename Utility and AdvancedRenamer.
How to Use Bulk Rename Utility
Bulk Rename Utility has a cluttered and somewhat intimidating interface, but it exposes the
huge number of options youd normally only get with regular expressions and complicated
command-line options.
After installing the tool, launch it, navigate to the files you want to rename, and select them.

Change options in one or more of the many available panels, and youll see a preview of your
changes appear in the New Name column where your files are listed. In this example, Ive
made changes to four panels, which are now highlighted in orange so its easier to tell what Ive
changed. Ive told the utility to change the name of all files to Word File and to use title case.
Ive appended the date the file was created in the YMD format. And Ive also added an
automatic file number that appears at the end of the file name, starts at one, increments by one,
and is separated from the file name by an underscore. And thats only a tiny bit of what you can
do with the Bulk Rename Utility. When youre satisfied with how your new file names will look,
all you have to do is click the Rename button.

And as you can see, the utility handled my simple requests with ease.
How to Use AdvancedRenamer
Our other favorite renaming tool, AdvancedRenamer, also exposes a huge number of renaming
methods, but instead of presenting them all as panels in the interface, it asks that you use a
pretty simple but powerful syntax to create renaming methods. Its not hard to learn and they
have good support, along with examples. The tool does sport a much friendlier interface and
supports setting up advanced batch jobs so you can combine multiple renaming methods and
apply them to large numbers of files. You can also save renaming methods you create for later
use.
In the example below, Ive created a renaming method using the following syntax:

Word File_<Year>_<Month>_<Day>_(<Inc Nr:1>)

This tells AdvancedRenamer to name all my files Word File and to add the creation date in the
YMD format (separating each portion by an underscore). It also adds an incremental file number
in parentheses and separated by an additional underscore.

And as you can see, my files have been renamed just the way I want. AdvancedRenamer has a
bit steeper learning curve than Bulk File Renamer, but the reward for that is that you get much
finer control over your file names.

Das könnte Ihnen auch gefallen