Batch File Renaming, renaming multiple files using PowerShell

Pubblicato il: 15 settembre 2023
sul canale di: 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.


In questa pagina del sito puoi guardare il video online Batch File Renaming, renaming multiple files using PowerShell della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Power Reconcile 15 settembre 2023, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 21,887 volte e gli è piaciuto 71 spettatori. Buona visione!