Need to rename a bunch files? Here are 3 ways to do it quickly on Window 10

How to rename multiple files using PowerShell

On Windows 10, PowerShell is a scripting tool, similar to Command Prompt, which allows you to rename files virtually any way you want. Although there are many ways to use PowerShell to manipulate files, these instructions walk you through the most common scenarios to rename one as well as various files at the same time.

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 you want to rename and press Enter:

    cd Documents\files

    PowerShell browser known folder location

    Source: Windows Central
    Quick note: The above command opens the “files” folder inside “Documents,” but you can use cd c:\users\USER-FOLDER-NAME\PATH\TO\FOLDER example syntax to navigate to other folder locations.

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

    dir

  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, the quotation marks are only required if the name includes spaces.

    This example renames the file to “summer_trip_2020_notes.txt”:

    Rename-Item hiking_trip_notes.txt summer_trip_2020_notes.txt

    PowerShell rename one file

    Source: Windows Central

Once you complete the steps, you may need to repeat step No. 5 to continue renaming other files.

Rename multiple files in bulk

To rename multiple files in bulk, when the name structure isn’t important, 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 you want to rename and press Enter:

    cd Documents\files

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

    dir

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

    Dir | %{Rename-Item $_ -NewName ("NEW-FILE-NAME{0}.EXTENSION" -f $nr++)}

    This example renames images with a “.jpg” extension using the same (“beach_trip_2020”) naming structure and appends a different number at the end of the name:

    Dir | %{Rename-Item $_ -NewName ("beach_trip_2020{0}.jpg" -f $nr++)}

    PowerShell rename multiple files command

    Source: Windows Central

After you complete these steps, all the files with the format you specified will rename using your configuration.

Trim multiple file names

To make file names shorter, or trim part of the names by an N number of characters, 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 you want to rename and press Enter:

    cd Documents\files

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

    dir

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

    Dir | Rename-Item -NewName {$_.name.substring(0,$_.BaseName.length-N) + $_.Extension}

    In the command update, “$_.BaseName.length-N” by changing the value of “N” to specify the number of characters that you want to remove.

    This example will trim the name of your files by eight characters:

    Dir | Rename-Item -NewName {$_.name.substring(0,$_.BaseName.length-8) + $_.Extension}

    PowerShell trim multiple filenames command

    Source: Windows Central

Once you complete these steps, you’ll 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.
  3. Type the following command example to navigate to the folder with the files you want to rename and press Enter:

    cd Documents\files

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

    dir

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

    Dir | Rename-Item -NewName {$_.name -replace "OLD-FILE-NAME-PART",""}

    This example removes the word “trip” from the name of all files in the folder:

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

    PowerShell remote part of filenames command

    Source: Windows Central

After you complete these steps, the command will delete the part of the filenames that 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.
  3. Type the following command example to navigate to the folder with the files you want to rename and press Enter:

    cd Documents\files

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

    dir

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

    Dir | Rename-Item -NewName {$_.name -replace "OLD-FILE-NAME-PART,"NEW-FILE-NAME-PART"}

    This example replaces the word “vacation_” for “hiking_trip_” on the file name:

    Dir | Rename-Item -NewName {$_.name -replace "vacation_","hiking_trip_"}

    PowerShell replace part of the name command

    Source: Windows Central

Once you complete these steps, the command will modify the part of the filenames with the replacement you specified in the command.

Remove spaces from multiple files

Spaces within the file names can sometimes cause issues, especially when using a command line. If you have filenames with spaces, you can modify the name to include a visual separator, such as a dash or underscore symbol.

To remove and replace spaces with underscores, 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 you want to rename and press Enter:

    cd Documents\files

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

    dir

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

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

    This example replaces spaces with underscores in all files:

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

    PowerShell remove spaces filenames command

    Source: Windows Central

After you complete these steps, the spaces within the filenames 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.
  3. Type the following command example to navigate to the folder with the files you want to rename and press Enter:

    cd Documents\files

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

    dir

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

    Dir | Rename-Item -NewName { [io.path]::ChangeExtension($_.name, "NEW-EXTENSION") }

    This example changes any file extension to “.doc”:

    Dir | Rename-Item -NewName { [io.path]::ChangeExtension($_.name, "doc") }

    PowerShell change file extension command

    Source: Windows Central

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

Rename specific extension file names

The previous instructions are meant to rename every file within the folder location. However, if you want to rename a particular file format, such as documents, pictures, or videos, then you can use the “-filter” option.

To change the names of a specific file format, 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 you want to rename and press Enter:

    cd Documents\files

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

    dir

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

    Dir -filter *.EXTENSION | %{Rename-Item $_ -NewName ("NEW-FILE-NAME{0}.EXTENSION" -f $nr++)}

    This example renames only files that include the “.jpg” extension:

    Dir -filter *.jpg | %{Rename-Item $_ -NewName ("beach_trip_{0}.jpg" -f $nr++)}

    PowerShell select extension rename command

    Source: Windows Central

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

Although these commands have been tested to work as expected, it’s always recommended that you perform a test run before trying to rename the original files.

More Windows 10 resources

For more helpful articles, coverage, and answers to common questions about Windows 10, visit the following resources:

Leave a Reply

Discover more from Ultimatepocket

Subscribe now to keep reading and get access to the full archive.

Continue reading