I'm trying to generate a list of all known files on a file share with Attributes Archive
and Offline
.
But I keep running into PathTooLongException
errors.
So far I've only found that Robocopy can work past the file length errors except that I can't get the same sort of "these attributes only" sort of results.
Example:
Get-ChildItem -Attributes A+O -Recurse |Export-Csv E:\temp\StubSearchCorp.csv
Gives:
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. At line:1 char:1 + Get-ChildItem -Attributes A+O -Recurse |Export-Csv E:\temp\StubSearchA.Corp.cs ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ReadError: (F:\Corporate\...e A Train & Ship:String) [Get-ChildItem], PathTooLongException + FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
Is anyone aware of a way I can export to CSV a list like this?
Best Answer
Robocopy is a swiss army knife with MANY options. I think all other tools will suffer from the path too long error. Do you really need all the properties that Get-ChildItem produces in the CSV, or are you only interested in a list of fully qualified file names? If the latter, try this:
/L produces a list without copying data.
/FP includes the full path instead of just the file name.
/NP suppresses % progress messages in the log
See the "file selection options" from the Robocopy usage:
/IA:[RASHCNETO] :: Include only files with any of the given Attributes set