You are on page 1of 28

How to batch rename multiple files on Windows 10

windowscentral.com/how-rename-multiple-files-bulk-windows-10

February 2, 2021

2 of 3

How to rename multiple files using PowerShell


Alternatively, you can also use PowerShell to rename one or multiple files. Although using
this tool, there are many ways to manipulate files, the instruction in this guide are only
meant to get started with the most common scenarios.

Rename single file


To rename only one file using PowerShell, use these steps:

1. Open Start.
2. Search for PowerShell and click the top result to open the app.
3. Type the following command example to navigate to the folder with the files to
rename and press Enter:

cd PATH\TO\FOLDER

In the command, replace PATH\TO\FOLDER with the actual path to the location.

For example, this command navigates the "files" folder inside "Documents":

cd Documents\files

Source: Windows Central

1/16
4. (Optional) Type the following command to view a listing of the files in the location
and press Enter:

ls

5. Type the following command to change the name of a single file and press Enter:

Rename-Item "OLD-FILE-NAME.EXTENSION" "NEW-FILE-NAME.EXTENSION"

In the command, make sure to specify the old and new file name and extension. The
quotation marks are only required if the name includes spaces.

For example, renames the file to "hiking_trip_2021_notes.txt":

Rename-Item summer_trip_21_notes.txt hiking_trip_2021_notes.txt

Source: Windows Central

6. Repeat step No. 5 to continue renaming other the remaining files.

Once you complete the steps, the command will change the name of the file you specified.

Rename multiple files in bulk


To rename multiple files in bulk, when the name structure is not important, use these
steps:

1. Open Start.
2. Search for PowerShell and click the top result to open the app.

2/16
3. Type the following command example to navigate to the folder with the files to
rename and press Enter:

cd PATH\TO\FOLDER

In the command, replace PATH\TO\FOLDER with the actual path to the location.

For example, this command navigates the "files" folder inside "Documents":

cd Documents\files

Source: Windows Central

4. (Optional) Type the following command to view a listing of the files in the location
and press Enter:

ls

3/16
5. Type the following command to rename multiple files in bulk and press Enter:

ls | %{Rename-Item $_ -NewName ("NEW-FILE-NAME-{0}.EXTENSION" -f


$nr++)}

In the command, replace "NEW-FILE-NAME" with the actual structure name you
want to use.

For example, this command renames images with a ".jpg" extension using the same
("beach-trip-2021-") naming structure and appends a different number at the end of
the name:

ls | %{Rename-Item $_ -NewName ("beach-trip-2021-{0}.jpg" -f


$nr++)}

Source: Windows Central

After you complete these steps, all the files with the specified format will be renamed
using the naming structure you specified.

Trim multiple file names


To make file names shorter, or trim part of the names by an "N" number of characters on
Windows 10, use these steps:

1. Open Start.
2. Search for PowerShell and click the top result to open the app.

4/16
3. Type the following command example to navigate to the folder with the files to
rename and press Enter:

cd PATH\TO\FOLDER

In the command, replace PATH\TO\FOLDER with the actual path to the location.

For example, this command navigates the "files" folder inside "Documents":

cd Documents\files

Source: Windows Central

4. (Optional) Type the following command to view a listing of the files in the location
and press Enter:

ls

5/16
5. Type the following command to rename files using shorter names and press Enter:

ls | Rename-Item -NewName {$_.name.substring(0,$_.BaseName.length-N)


+ $_.Extension}

In the command, inside "$_.BaseName.length-N" update the value of "N" to specify


the number of characters that you want to remove.

For example, this command trims the name of your files by eight characters:

ls | Rename-Item -NewName {$_.name.substring(0,$_.BaseName.length-8)


+ $_.Extension}

Source: Windows Central

Once you complete these steps, you will end up with shorter file names depending on the
length you specified in the command.

Delete part of the name from multiple files


To remove part of the file name on multiple files with PowerShell, use these steps:

1. Open Start.
2. Search for PowerShell and click the top result to open the app.

6/16
3. Type the following command example to navigate to the folder with the files to
rename and press Enter:

cd PATH\TO\FOLDER

In the command, replace PATH\TO\FOLDER with the actual path to the location.

For example, this command navigates the "files" folder inside "Documents":

cd Documents\files

Source: Windows Central

4. (Optional) Type the following command to view a listing of the files in the location
and press Enter:

ls

7/16
5. Type the following command to remove part of the file name and press Enter:

ls | Rename-Item -NewName {$_.name -replace "OLD-FILE-NAME-


PART",""}

In the command, replace "OLD-FILE-NAME-PART" with the actual part of the


name you want to replace.

For example, this command removes the word "trip" from the name of all files in the
folder:

ls | Rename-Item -NewName {$_.name -replace "trip",""}

Source: Windows Central

After you complete the steps, the command will remove the part of the file name you
specified in the command.

Replace part of the name from multiple files


To rename the same part of the file name, use these steps:

1. Open Start.
2. Search for PowerShell and click the top result to open the app.

8/16
3. Type the following command example to navigate to the folder with the files to
rename and press Enter:

cd PATH\TO\FOLDER

In the command, replace PATH\TO\FOLDER with the actual path to the location.

For example, this command navigates the "files" folder inside "Documents":

cd Documents\files

Source: Windows Central

4. (Optional) Type the following command to view a listing of the files in the location
and press Enter:

ls

9/16
5. Type the following command to replace part of file name and press Enter:

ls | Rename-Item -NewName {$_.name -replace "OLD-FILE-NAME-


PART","NEW-FILE-NAME-PART"}

In the command, replace "OLD-FILE-NAME-PART" and "NEW-FILE-NAME-


PART" with the old and new part of the file name.

For example, this command replaces the word "vacation_" for "hiking_trip_" on the
file name:

ls | Rename-Item -NewName {$_.name -replace "beach--


","hiking_trip_"}

Source: Windows Central

Once you complete these steps, the command will modify the file names with the
replacement you specified in the command.

Remove spaces from multiple files


Spaces as part of the file name can sometimes cause problems, even more, when using a
command console. If you have files that contain spaces in their names, you can use
PowerShell to replace the character for a visual separator, such as a dash or underscore
symbol.

To remove and replace spaces with underscores in file names, use these steps:

1. Open Start.
2. Search for PowerShell and click the top result to open the app.

10/16
3. Type the following command example to navigate to the folder with the files to
rename and press Enter:

cd PATH\TO\FOLDER

In the command, replace PATH\TO\FOLDER with the actual path to the location.

For example, this command navigates the "files" folder inside "Documents":

cd Documents\files

Source: Windows Central

4. (Optional) Type the following command to view a listing of the files in the location
and press Enter:

ls

11/16
5. Type the following command to remove spaces from file name and press Enter:

ls | Rename-Item -NewName { $_.Name -replace " ","SEPARATOR" }

In the command, make sure to replace "SEPARATOR" with the symbol you want to
use instead of a space.

For example, this command replaces spaces with underscores in all the files:

ls | Rename-Item -NewName { $_.Name -replace " ","_" }

Source: Windows Central

After you complete the steps, the file names' spaces will be replaced with the separator
you specified.

Change file extension


To change the file extension for a bunch of files with PowerShell, use these steps:

1. Open Start.
2. Search for PowerShell and click the top result to open the app.

12/16
3. Type the following command example to navigate to the folder with the files to
rename and press Enter:

cd PATH\TO\FOLDER

In the command, replace PATH\TO\FOLDER with the actual path to the location.

For example, this command navigates the "files" folder inside "Documents":

cd Documents\files

Source: Windows Central

4. (Optional) Type the following command to view a listing of the files in the location
and press Enter:

ls

13/16
5. Type the following command to change the extension on files and press Enter:

ls | Rename-Item -NewName { [io.path]::ChangeExtension($_.name,


".NEW-EXTENSION") }

In the command, replace ".NEW-EXTENSION" with a new extension for the files.

For example, this command changes any file extension to ".doc":

ls | Rename-Item -NewName { [io.path]::ChangeExtension($_.name,


"doc") }

Source: Windows Central

Once you complete the steps, PowerShell will change the extension to the one you
specified.

Rename specific extension file names


The above instructions will rename every file within the folder location. However, if you
want to change the name of a particular file format, such as documents, pictures, or
videos, you can use the "-filter" option.

To change the names of a specific file format with PowerShell commands, use these steps:

1. Open Start.
2. Search for PowerShell and click the top result to open the app.

14/16
3. Type the following command example to navigate to the folder with the files to
rename and press Enter:

cd PATH\TO\FOLDER

In the command, replace PATH\TO\FOLDER with the actual path to the location.

For example, this command navigates the "files" folder inside "Documents":

cd Documents\files

Source: Windows Central

4. (Optional) Type the following command to view a listing of the files in the location
and press Enter:

ls

15/16
5. Type the following command to rename files with a specific extension and press
Enter:

ls -filter *.EXTENSION | %{Rename-Item $_ -NewName ("NEW-FILE-NAME-


{0}.EXTENSION" -f $nr++)}

In the command, replace "NEW-FILE-NAME" and "EXTENSION" with the


parameter you want to use.

For example, this command renames only files that include the ".jpg" extension:

ls -filter *.jpg | %{Rename-Item $_ -NewName ("beach-trip-{0}.jpg" -


f $nr++)}

Source: Windows Central

Once you complete the steps, PowerShell will rename the files with a specific extension
using the name you specified in the command.

2 of 3

16/16
How to batch rename multiple files on Windows 10
windowscentral.com/how-rename-multiple-files-bulk-windows-10

February 2, 2021

3 of 3 Next

How to rename multiple files using Command Prompt


On Windows 10, Command Prompt also offers multiple ways to change the name of one
or multiple files in bulk.

Rename single file


To rename one file with Command Prompt on Windows 10, use these steps:

1. Open Start.
2. Search for Command Prompt and click the top result to open the app.
3. Type the following command example to navigate to the folder with the files to
rename and press Enter:

cd c:\PATH\TO\FILES

For instance, this example opens the "files" folder inside "Documents":

cd %USERPROFILE%\Documents\files

Source: Windows Central

1/12
4. Type the following command to view a listing of the files in the location and press
Enter:

dir

5. Type the following command to rename the file and press Enter:

ren "OLD-FILENAME.EXTENSION" "NEW-FILENAME.EXTENSION"

In the command, replace "OLD-FILENAME.EXTENSION" and "NEW-


FILENAME.EXTENSION" with the old and new file name you want. The quotation
marks are only required if the name includes spaces.

For instance, this commands renames the file to "summer_trip_21_notes.txt":

ren summer_trip_21_notes.txt summer_vacation_21_notes.txt

Source: Windows Central

6. Repeat step No. 5 to change the name of the remaining files

Once you complete these steps, Command Prompt will rename the file with the new name
you specified.

Rename multiple files


To rename multiple files in bulk with the same name structure with Command Prompt,
use these steps:

1. Open Start.
2. Search for Command Prompt and click the top result to open the app.

2/12
3. Type the following command example to navigate to the folder with the files to
rename and press Enter:

cd c:\PATH\TO\FILES

For instance, this example opens the "files" folder inside "Documents":

cd %USERPROFILE%\Documents\files

4. (Optional) Type the following command to view a listing of the files in the location
and press Enter:

dir

3/12
5. Type the following command to rename the files in bulk and press Enter:

ren *.FILE-EXTENSION ???-FILE-NAME.*

In the command, replace "FILE-EXTENSION" with the extension of the files you
want to update and "FILE-NAME" with part of the name you want to add to all the
files. The asterisk * is a wildcard that tells the ren command to rename everything
with a specific extension. The question mark ? is also a wildcard, but it represents
a character of the original name you want to keep as part of the new name.

For instance, this command renames all ".jpg" files leaving the first three characters
(which works as a unique identifier to avoid duplication) and appends "-
hikingTrails" to the name:

ren *.jpg ???-hikingTrip.*

Source: Windows Central

Quick tip: When renaming files, the ren command sees a period (.) as the end of
the filename. This means that if you have files with one or more periods as part of
the name, the command may produce unexpected results.

After you complete the steps, the files will be renamed using the settings you specified.

Trim multiple file names


To make file names shorter with Command Prompt, use these steps:

1. Open Start.
2. Search for Command Prompt and click the top result to open the app.

4/12
3. Type the following command example to navigate to the folder with the files to
rename and press Enter:

cd c:\PATH\TO\FILES

This example opens the "files" folder inside "Documents":

cd %USERPROFILE%\Documents\files

Source: Windows Central

4. (Optional) Type the following command to view a listing of the files in the location
and press Enter:

dir

5/12
5. Type the following command to make file names shorter and press Enter:

ren *.* ?????.*

In the command, the asterisk * matches all the file names and extensions in the
folder, and the question marks ? indicate how many characters to use for the new
file name.

For instance, this command trims the file names longer than five characters:

ren *.* ?????.*

Source: Windows Central

If the file name has less than five characters, the name will not change. (If you want
to make the file name longer, add extra question marks in the syntax.)

Once you complete these steps, you will end up with shorter file names depending on the
question marks (?) you specified in the command.

Modify multiple file names


To rename part of the name on similar files, use these steps:

1. Open Start.
2. Search for Command Prompt and click the top result to open the app.

6/12
3. Type the following command example to navigate to the folder with the files to
rename and press Enter:

cd c:\PATH\TO\FILES

This example opens the "files" folder inside "Documents":

cd %USERPROFILE%\Documents\files

Source: Windows Central

4. (Optional) Type the following command to view a listing of the files in the location
and press Enter:

dir

7/12
5. Type the following command to rename the part of the file name and press Enter:

ren OLD-FILE-NAME-PART*.* NEW-FILENAME-PART*.*

In the command, replace "OLD-FILE-NAME-PART" and "NEW-FILENAME-PART"


with the old and new parts of the filename. The asterisk * is a wildcard that will
match the rest of the filename and file extension to append the new part of the
name.

For instance, this command renames files that start with "summer_trip_21" to
"vacation_2021":

ren summer_trip_21*.* vacation_2021*.*

Source: Windows Central

After you complete the steps, the files with similar names will be modified with the new
name structure you specified in the command.

Change file extension


To change the file extension to another compatible extension on Windows 10, use these
steps:

1. Open Start.
2. Search for Command Prompt and click the top result to open the app.

8/12
3. Type the following command example to navigate to the folder with the files you
want to rename and press Enter:

cd c:\PATH\TO\FILES

This example opens the "files" folder inside "Documents":

cd %USERPROFILE%\Documents\files

Source: Windows Central

4. (Optional) Type the following command to view a listing of the files in the location
and press Enter:

dir

9/12
5. Type the following command to change the file extension and press Enter:

ren *.OLD-EXTENSION *.NEW-EXTENSION

In the command, change "OLD-EXTENSION" and "NEW-EXTENSION" with the


old and new file extension.

For instance, this command changes the extension from ".txt" to ".doc" compatible
with Microsoft Word for the files in the location:

ren *.txt *.doc

This example without wildcards ( * ) changes the only extension of a single file from
".txt" to ".doc":

ren vacation_2021_notes.txt vacation_2021_notes.doc

Source: Windows Central

Once you complete the steps, the file extension will be replaced with the new extension
specified in the command.

Rename files with specific extension


The previous steps rename every file within the location. However, if you want to rename
only a group of files with a specific format, you need to omit the asterisk * and specify
the command's target extension.

To rename files with a specific file extension on Windows 10 with Command Prompt, use
these steps:

1. Open Start.

10/12
2. Search for Command Prompt and click the top result to open the app.
3. Type the following command example to navigate to the folder with the files to
rename and press Enter:

cd c:\PATH\TO\FILES

This example opens the "files" folder inside "Documents":

cd %USERPROFILE%\Documents\files

Source: Windows Central

4. (Optional) Type the following command to view a listing of the files in the location
and press Enter:

dir

11/12
5. Type the following command to change the file extension in the location and press
Enter:

ren OLD-FILE-NAME*.EXTENSION NEW-FILE-NAME*.EXTENSION

In the command, change "OLD-FILE-NAME," "NEW-FILE-NAME," and


"EXTENSION" with the old and new file name and extension you want to target.

For instance, this command only renames images with a ".jpg" extension:

ren picture-*.jpg vacation*.jpg

Source: Windows Central

After you complete the steps, Command Prompt will rename the files using the settings
that you specified in the command.

While these commands have been tested to work as expected, it is always recommended
that you perform a test run before trying to rename the original files on your computer.

12/12

You might also like