Windows CLI - Find long Filepaths and compress to zip



  • I'm looking for a way with Windows CLI or Powershell to scan for and find long file paths on a server (those exceeding the default limit) and compress the top 3 parent folders into a zip file that matches the uppermost folder name.

    Anyone have anything that would work?



  • There is like no one publishing how to do this, which is really weird. Finding long filenames is apparently really hard.

    Here is what StackOverflow says to do.

    dir /s /b > out.txt
    cmd /c dir /s /b |? {$_.length -gt 260}
    

    In PowerShell. That would produce the list, apparently. Then from there, there is a list to compress from.



  • Long file names can be a serious pain... for copy and backup reasons.

    I recall a NTG client that used a long name for the directories,.. and it made updating nearly impossible Should follow the KISS method... Directory names don't need to be 120 characters long,.. and four deep.