How to? Filter file-contents based on "IF EXIST"

#1
I have a file that contains names of other files or dirs. Now I want to create a 2nd file with the reduced list of files that actually exist.

I'm pretty sure that I'll manage to write a loop to do this, but I'd like to level up my TC-knowledge and was wondering if it wouldn't be nice to do this with a TPIPE and perhaps /run - but the doc still scares me - so I thought I'll ask the Pros before trying to get it done all by myself... ;-)
 

samintz

Scott Mintz
May 20, 2008
1,295
11
Solon, OH, USA
#2
Assuming your file that contains the names is named foo.txt:
Code:
(type foo.txt & dir /b) | tpipe /dup=1,0,1,100,0,"%%1:s"
That creates list of names to stdout and passes that to tpipe. Tpipe will filter the list and only output those lines that have duplicates. The DIR /B command will list the files that exist.

-Scott
 

samintz

Scott Mintz
May 20, 2008
1,295
11
Solon, OH, USA
#3
It doesn't look like you can specify a length of -1 or 0 to say use the whole line. So set a length you know is long enough. I used 100 in my example, but you could make it 32768 and that works too.