Skip to content

Instantly share code, notes, and snippets.

@tomarbuthnot
Created September 9, 2014 19:46
Show Gist options
  • Save tomarbuthnot/a0b903da2aea0398e454 to your computer and use it in GitHub Desktop.
Save tomarbuthnot/a0b903da2aea0398e454 to your computer and use it in GitHub Desktop.
Rename Long Filenames
$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