Back to PowerShell today!

I had few files to be renamed and they were about 500 odd of them. Renaming each and every file by hand would be a real pain. I thought of writing a PowerShell one liner to get this thing done and to my surprise it did my job in a few seconds.

Here is the scenario:

I have files with names like

text1.txt
text2.txt
text3.txt

I don’t like the naming format and wanted them in “Number(dot)(space)(FileName)(Extension)” i.e.

1. text.txt
2. text.txt and so on….

Here is a cool simple script to do this dirty job:

Get-ChildItem *.txt | Rename-Item -NewName { $_.name -replace 'text(\d+)', '$1. text'}

HTH