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

difference between wuauclt1.exe and wuauclt.exe

Windows 2016 RDS event 1306 Connection Broker Client failed to redirect the user... Error: NULL