Author Posts

January 1, 2012 at 12:00 am

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={$} | 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:

Otherwise check my script there that uses [system.IO.Directory]::GetFiles and [system.IO.Directory]::GetDirectories: