I am trying to output to a text file, all files on a network drive which have a path length greater than x (currently 250).
I have been trying to use the below solution that rerun posted:
How do I find files with a path length greater than 260 characters in Windows?
In powershell cmd /c dir /s /b |? {$_.length -gt 250}
This solution seems to work but has two problems:
- It is displayed in the Powershell window, not output to a file
- Powershell formats the windowed results so that one file path is shown over multiple lines. I tried to copy and paste the results from Powershell into an Excel document, but they are pasted over multiple lines in Excel too, and I need each file path on one line
I have changed this solution supplied by rerun to the below:
cmd /c dir /s /b |? {$_.length -gt 250} | Out-File C:\results.txt -width 1500
This now resolves the above two problems, but I run into another issue. I get an error message in the Powershell window when I run it, saying 'The directory name xxxxxxxx is too long'. Checking the file reveals that not all the files have been output to it. Does anybody have an idea of how I can achieve this please? Cheers