Add to Technorati Favorites
Welcome to ThePowerShellGuy.com Sign in | Join | Help

Hey PowerShell Guy! How Can I Replace Incorrect Dates in My File Names?

No solutions to post today , so time for a small Hey scripting guy ! translation : How Can I Replace Incorrect Dates in My File Names? 

dir *.jpg | ren -new {$_.name -replace "(\d{1,2})-(\d{1,2})-07",'$1-$2-08' }

To keep the example clear I used exactly the same regex as the scripting guy did.

this is a typical example how powerfull scriptblock parameters are in PowerShell, combined with the -replace operators regex support in PowerShell.

for a more complete explanation see this post on my former blog : /\/\o\/\/ PowerShelled: PowerShell : Advanced renaming of files  where I cover advanced renaming of files in PowerShell this way in much more detail.

Enjoy,

Greetings /\/\o\/\/

 

Published Monday, February 25, 2008 2:38 PM by MoW
Filed under: ,

Comments

# re: Hey PowerShell Guy! How Can I Replace Incorrect Dates in My File Names?

Yesterday i tried to rename a bunch of files and got a weird msg with the following syntax.

foreach($item in (ls *.mp4)){

rename-item $item     $item.Name.Replace("example","")

}

might have some typos but i'am not @home actually.

No Element found under {insert fullpath}

Well i found out that i had withespaces on the path and was wpndering how to resolve that.

greetings from germany

Thursday, April 17, 2008 3:05 AM by elster
Anonymous comments are disabled