• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 79
  • Last Modified:

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?
0
McThump
Asked:
McThump
  • 2
1 Solution
 
Jason CrawfordTransport 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

2
 
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}}
1
 
Jason CrawfordTransport NinjaCommented:
Glad I could help.  Take care :)
0
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.

Join & Write a Comment

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now