Writing files of a folder and subfolders in a txt

Copper Contributor

hello i need to list all files of a folder and its subfolders (just files, no folders, possibly a simple list) i'm using this command but i get an error. It seems like it gets stuck with a file name which is too long. If i run the get child command without the print part, it works, but i need my results printed in a file! How to fix? thank you

 

 

 

Get-ChildItem -Path 'c:\mypath\' -File -Recurse | Out-File -FilePath 'c:\mypath\files.txt'

 

 

 

 

 

 

 

Get-ChildItem : The tag present in the reparse point buffer is invalid.
At line:1 char:1
+ Get-ChildItem -Path 'C:\Users\XXX ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ReadError: (C:\Users\XXXX:String) [Get-ChildItem], IOExcep
tion
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand

 

 

1 Reply

@antonioaunix 

 

The error explicitly relates to reparse point tags, not path length.

 

Here's some information on reparse points.

 

Reparse Points - Win32 apps | Microsoft Docs

Reparse Point Tags - Win32 apps | Microsoft Docs

 

This specific error will only surface on a per file or per directory basis.

 

You could try this as an alternative. Looking at the .NET reference, it may avoid the reparse error (if, for example, that information comes via calling a method), but since I can't reproduce a reparse error to begin with, it may end up exactly the same. All you can do is try it and see.

 

[System.IO.Directory]::GetFileSystemEntries("D:\Data", "*", [System.IO.SearchOption]::AllDirectories) | % { [System.IO.FileInfo]::new($_) | select Length, LastWriteTime, FullName }

 

Cheers,

Lain