Marc W
Marc W

Reputation: 101

How can you get the fullname, path plus filename from ls?

I can for example do this:

PS C:\Builds\Main\> ls "C:\Builds\Main\Prod\Core\prodXML\prodXML\prodXMLElement.cpp" -Name

but then the output is prodXMLElement.cpp.

I want to pipe the output of ls to a console program that expects the full file name, including the directory, so I want to get:

C:\Builds\Main\Prod\Core\prodXML\prodXML\prodXMLElement.cpp

Upvotes: 2

Views: 2328

Answers (1)

Martin Brandl
Martin Brandl

Reputation: 58931

ls is an alias for Get-ChildItem so you will find plenty of information about this here (You can also find this information by typing Get-Help Get-ChildItem). To get the whole path, just omit the -Name switch. Depending what your pipe target expects, you may have to select the FullName.

Example:

Get-ChildItem -Filter '*.cpp' | Select-Object -ExpandProperty FullName

Upvotes: 4

Related Questions