Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Modifying GCI output for a picky application.

$
0
0

Hi Guys,

I want to get a list of all files (excluding directories) from a disk. I need them as paths, and I need them encased in quotes, as the programs I will be feeding the output into is quite picky about syntax. 

Say I have a directory tree like:

D:.
├───1
│   │   1.txt
│   │   2.txt
│   │
│   └───3
│           1.txt
│           2.txt

└───2
        1.txt
        2.txt

I've fiddled and looked about, but I cant find anything that gives me quite what I want. I got to this command: gci -r | where-object {$_.mode -lt "d"} | gci -n, which gives the output:

1.txt
2.txt
1.txt
2.txt
1.txt
2.txt

Unfortunately, I need

"D:\1\1.txt"
"D:\1\2.txt"
"D:\1\3\1.txt"
etc.

I'm fairly new to powershell, so I'm sorry if I've missed a blindingly simple way to do this.

Thanks in advance,

Mini


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>