Powershell script to rename files

Question:

I have a bunch of files that have names that start with numbers, may contain spaces and dashes after one of two numbers, then sometimes (sometimes not) have a space just before the first alpha character of the name I want to keep, i.e.:

2-01 Dazed And Confused.txt (I want to rename this to Dazed And Confused.txt)

Or

02 – Uncle Salty.txt (I want to rename this to Uncle Salty.txt)

Or

02-The Night Before.txt (I want to rename to The Night Before.txt)

Answer:


If you need to recursively process YourDirectory, add -recurse after dir.

Source:

Powershell script to rename files by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply