Batch File Renaming, renaming multiple files using PowerShell

Veröffentlicht am: 15 September 2023
auf dem Kanal: Power Reconcile
21,887
71

Rename multiple files using Windows PowerShell

#powershell #files-renaming

Windows PowerShell is very powerful. In today’s case study, let’s see how we can use it to rename multiple files.

Let’s say we used Power PDF Filler to automatically populated multiple PDF forms. Now we want to remove the preceding digits and the dot from all the PDF files.

Here's how you can do it:

1. Open PowerShell
Press Win + X and select "Windows PowerShell" from the Power User menu.
Navigate to the Directory:
Use the cd command to navigate to the directory containing the files you want to rename.

2. Use the following PowerShell script to rename the files.

Get-ChildItem -Filter '*.pdf' | ForEach-Object { Rename-Item $_.FullName -NewName ($_.Name -replace '^\d+\.', '') }

Here's a breakdown of what's happening.

Get-ChildItem -Filter '*.pdf' - Retrieves all files in the directory with a .pdf extension.
ForEach-Object { ... } - Iterates through each file.
Rename-Item $_.FullName -NewName ($_.Name -replace '^\d+\.', '') - Renames the file by replacing the pattern (digit). at the start of the name with an empty string.

After running this script, your files should be renamed as per your requirement.

Remember to back up your files before performing batch operations like this.

Thank you for watching.


Auf dieser Seite können Sie das Online-Video Batch File Renaming, renaming multiple files using PowerShell mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Power Reconcile 15 September 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 21,887 Mal angesehen und es wurde von 71 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!