Created
June 24, 2015 15:17
-
-
Save jaboc83/1522b42fc2d643b37585 to your computer and use it in GitHub Desktop.
Delete Long File Names in Windows
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
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory=$True, Position=1)] | |
$Filter | |
) | |
$batFileContent = @" | |
mkdir a | |
robocopy a %1 /s /mir | |
rmdir a | |
rmdir %1 | |
"@ | |
$batFileName = "long.bat" | |
if (-not (Test-Path $batFileName)) { | |
$batFileContent | Out-File $batFileName -Encoding ascii | |
} | |
Get-ChildItem $Filter | ForEach { ./long.bat $_.FullName | Write-Output } | |
if (Test-Path $batFileName) { | |
Remove-Item $batFileName | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a simple script for deleting files with names too long for windows to normally delete. My buildserver has folders in the format
100.tcbuildid, 101.tcbuildid, 102.tcbuildid, etc...
. so I can easily clean the bad files out using this command like so: