Hopeless Hopeless - 3 months ago 24
PowerShell Question

Combine root path with several child paths

How can I combine several paths, for ex.: file1, file2, file3 with root C:?

I know that possible this:

Join-Path C:\, D:\, E:\ file


Output:

C:\file
D:\file
E:\file


I need conversely, something like:

Join-Path C:\ file1, file2, file3


And output:

C:\file1
C:\file2
C:\file3


But this doesn't work.

Answer
"file1","file2","file3" | %{ Join-Path c:\ $_ }

c:\file1
c:\file2
c:\file3