Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell - how do I list files and write their path into an output file?

I want to list *.xml files which are in several subdirectories. Then I want to write their path and their names into an txt file. I managed to write the names into an txt file, however, I have no idea how to add their paths. What do I need to change/add?

Get-ChildItem path -recurse -include *.xml| ForEach-Object { $_.Name } > path\output.txt

Thank you for your help! Cheers, Iris

like image 972
Iris Avatar asked Jan 16 '14 13:01

Iris


1 Answers

FullName will print the full path to the file.

Get-ChildItem path -recurse -include *.xml| ForEach-Object { $_.FullName } > path\output.txt

Here's a list of properties that the object returned in this instance provides: FileInfo Class

like image 156
David Martin Avatar answered Sep 28 '22 10:09

David Martin