Created
September 9, 2014 19:46
-
-
Save tomarbuthnot/a0b903da2aea0398e454 to your computer and use it in GitHub Desktop.
Rename Long Filenames
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$longnames = Get-ChildItem -Path "C:\Users\Tom\OneDrive\Documents\Microsoft\Nexthop Archive\" -Recurse | select-object fullname,name, @{Name="Nlength";Expression={$_.Name.Length}} | Where-Object Nlength -GT 35 | |
Foreach ($name in $longnames) | |
{ | |
$newname = "$($name.Name.Substring(0,6))" + ".html" | |
Write-Host $newname | |
Rename-Item -Path $name.Fullname -NewName $newname | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment