Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Rename a file with 21 characters only

$
0
0

I kept get error for the below script:

#rename file

ForEach ($i in Get-ChildItem -Path .) {

if ($i.Name -notmatch "myfile_Test_read_Full_20150503.")

{ continue }

Rename-Item $i.Name -NewName ($i.BaseName.Substring(0,21) +$i.Extension -replace "-","")

}

sleep -seconds 5

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles