Lagos, Nigeria
info@ezefidelity.com

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


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 PATHTOFOLDER

    In the command, replace PATHTOFOLDER with the actual path to the location.

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

    cd Documentsfiles

    Powershell navigation folder location

    Source: Windows Central

  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

    PowerShell rename one file

    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.
  3. Type the following command example to navigate to the folder with the files to rename and press Enter:

    cd PATHTOFOLDER

    In the command, replace PATHTOFOLDER with the actual path to the location.

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

    cd Documentsfiles

    Powershell navigation folder location

    Source: Windows Central

  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 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++)}

    PowerShell bulk rename multiple files

    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.
  3. Type the following command example to navigate to the folder with the files to rename and press Enter:

    cd PATHTOFOLDER

    In the command, replace PATHTOFOLDER with the actual path to the location.

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

    cd Documentsfiles

    Powershell navigation folder location

    Source: Windows Central

  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 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}

    PowerShell trim part of the file name

    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.
  3. Type the following command example to navigate to the folder with the files to rename and press Enter:

    cd PATHTOFOLDER

    In the command, replace PATHTOFOLDER with the actual path to the location.

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

    cd Documentsfiles

    Powershell navigation folder location

    Source: Windows Central

  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 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",""}

    PowerShell delete part of file name

    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.
  3. Type the following command example to navigate to the folder with the files to rename and press Enter:

    cd PATHTOFOLDER

    In the command, replace PATHTOFOLDER with the actual path to the location.

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

    cd Documentsfiles

    Powershell navigation folder location

    Source: Windows Central

  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 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_"}

    PowerShell rename part of file name

    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.
  3. Type the following command example to navigate to the folder with the files to rename and press Enter:

    cd PATHTOFOLDER

    In the command, replace PATHTOFOLDER with the actual path to the location.

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

    cd Documentsfiles

    Powershell navigation folder location

    Source: Windows Central

  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 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 " ","_" }

    PowerShell remove file name remove spaces

    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.
  3. Type the following command example to navigate to the folder with the files to rename and press Enter:

    cd PATHTOFOLDER

    In the command, replace PATHTOFOLDER with the actual path to the location.

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

    cd Documentsfiles

    Powershell navigation folder location

    Source: Windows Central

  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 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") }

    PowerShell change file extension

    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.
  3. Type the following command example to navigate to the folder with the files to rename and press Enter:

    cd PATHTOFOLDER

    In the command, replace PATHTOFOLDER with the actual path to the location.

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

    cd Documentsfiles

    Powershell navigation folder location

    Source: Windows Central

  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 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++)}

    PowerShell only rename specific extension files

    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.





This post was written by Mauro Huculak and was first posted to WindowsCentral



Do you find this article helpful? Your Friend might too. So, please Share it with them using the Share button above.
Will you like to get notified when I post new updates? Then Follow me on any of my social media handles: Google News, Telegram, WhatsApp, Twitter, Facebook, Pinterest.
You can also drop your email address below if you wish to be notified by mail.


Tags: ,

%d bloggers like this: