dir and Long UNC

Welcome Forums General PowerShell Q&A dir and Long UNC

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years ago.

  • Author
  • #5781

    Points: 0
    Rank: Member

    by lopyeg at 2013-04-07 12:12:50

    Hello powershell guys!
    I tried to do some grep with Get-ChildItem d:\ -Recurse | Where-Object {$_.Length -gt 1024MB}
    and i've got issue:
    Get-ChildItem : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
    i googled on this error – nothing got
    i tried \\?\D:\ – got an error
    i tried to divide long url and fix them in file? but error appeared earlier than IF ))
    Get-ChildItem d:\ -Recurse | Where-Object {$_.Length -gt 1024MB} |`
    %{if ($_.fullname.length -lt 260) {`
    Select-Object Name, @{Name="SizeInMB" ;Expression={$_.Length / 1MB}}, |`
    add-content greater1GBs.txt }`
    else {Select-Object Name, @{Name="Path";Expression={$_.directory} | add-content 260UNC.txt }}}

    Could i walk this problem around?
    Thank you for a help!!!

    by lopyeg at 2013-04-07 12:17:26

    it seems only robocopy could help

    by happysysadm at 2013-04-08 02:45:16

    Yes, Robocopy is a solution as stated by Boe Prox: http://learn-powershell.net/2013/04/01/list-all-files-regardless-of-260-character-path-restriction-using-powershell-and-robocopy/

    Otherwise check my script there that uses [system.IO.Directory]::GetFiles and [system.IO.Directory]::GetDirectories: http://www.happysysadm.com/2013/04/finding-paths-that-exceed-maxpath-with.html


The topic ‘dir and Long UNC’ is closed to new replies.