Rename files recursively


hi expert,

i having hard time renaming files within subfolders, have script:

get-childitem  -recurse | {$_.name -match "^(_2014-|2014-)"} | % { rename-item $_ "_000000$($_.name)"}

it rename files on current folder in subfolders keeps throwing error;

rename-item : cannot rename because item @ filename  does not exist. appreciated

regards

here again:

get-childitem  -recurse -file -include '2014*','_2014*' |       foreach-object{          rename-item $_.fullname ('{0}\_000000{1}' -f $_.directory.fullname,$_.name)      }
watch out ther no whatif time. 


¯\_(ツ)_/¯




Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Event ID 64,77,1008 Certificates Events Windows Server 2008, 2008R2