Script to list long file paths

Can someone suggest a PowerShell script that will list all file paths over 260 characters in the current folder and subfolders?
Who is Participating?
Jason CrawfordConnect With a Mentor Transport NinjaCommented:
This will write to console the full path of any file with a path containing greater than 260 characters

foreach ($file in (Get-ChildItem 'c:\insert\path' -Recurse)) {
  if ($file.fullname.length -gt 260) {
    Write-Host $file.fullname

Open in new window

AntzsInfrastructure ServicesCommented:
Try this in PowerShell.

Out-File c:\OutputFile.txt ; cmd /c "dir /b /s /a" | ForEach-Object { if ($_.length -gt 250) {$_ | Out-File -append c:\OutputFile.txt}}
Jason CrawfordTransport NinjaCommented:
Glad I could help.  Take care :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.