thotwielder
thotwielder

Reputation: 1707

powershell concatenate string with output of get-childitem

I want to add a path string to all file names returned by get-childitem from a folder.

I have tried something like

    Get-ChildItem  C:\path\folder |'different path' + {$}

I want to add a different path to all the file anmes returned from the folder. But it won't compile.

Upvotes: 0

Views: 1319

Answers (3)

Esperento57
Esperento57

Reputation: 17462

or this:

Get-ChildItem C:\temp -file | select @{N="Name";E={"different path {0}" -f $_.Name}}

Upvotes: 2

Esperento57
Esperento57

Reputation: 17462

try it:

Get-ChildItem C:\temp -file | %{"different path {0}" -f $_.Name}

Upvotes: 1

shree.pat18
shree.pat18

Reputation: 21757

You mean something like this?

Get-ChildItem -Name C:\path\folder | foreach {"different path $_"}

Upvotes: 0

Related Questions