Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Using AND (&&)

Jul
33
0
Hi,
I'm trying to use a simple && (AND) sequence. I've tried it in both Windows command line and TC. Here it is:

for %I in (*.pdf) do echo %I >> files.txt && pdfinfo %I >> files.txt

I want to write to a file the name of the PDF file I'm working on. Then, underneath that echoed line in the text file, I want to run a simple PDF utility that I use to interrogate the PDF for page count, etc.

All I'm getting is a text file with the names of the files, but, no PDF information. I know that the "pdfinfo" command is in my path because, as it's running this sequence, I see its nomenclature flying by.

I'm getting the same results with both Windows and TC.

Thanks.
 
Hi,
I'm trying to use a simple && (AND) sequence. I've tried it in both Windows command line and TC. Here it is:

for %I in (*.pdf) do echo %I >> files.txt && pdfinfo %I >> files.txt

I want to write to a file the name of the PDF file I'm working on. Then, underneath that echoed line in the text file, I want to run a simple PDF utility that I use to interrogate the PDF for page count, etc.

All I'm getting is a text file with the names of the files, but, no PDF information. I know that the "pdfinfo" command is in my path because, as it's running this sequence, I see its nomenclature flying by.

I'm getting the same results with both Windows and TC.

I'm not sure why you're using the conditional && -- perhaps you just want a command separator there?

Code:
for %I in (*.pdf) ( echo %I & pdfinfo %I ) >> files.txt
 
Thanks. Well, yours doesn't work in Windows, but it does run with TC. But, it yields only the list of filenames, no "pdfinfo" data.
 
I got it. I've got spacebands in my PDF filenames, so, I have to put quotes around my file variable.

for %I in ("*.pdf") ( echo "%I" & pdfinfo "%I" ) >> files.txt

Thanks a lot for your help. You guided me.
 
pb4072 wrote:
| I got it. I've got spacebands in my PDF filenames, so, I have to put
| quotes around my file variable.
|
| for %I in ("*.pdf") ( echo "%I" & pdfinfo "%I" ) >> files.txt

Notes:
1/ You do not need to quote the wild-card search expression unless it
contains whitespace etc.
2/ If you use the "noclobber" feature, a strong deterrent to accidental
overwriting, you need to create you output file explicitly, UNLESS
3/ You can make a single command group of the whole FOR like this:

( for %I in (*.pdf) ( echo "%I" & pdfinfo "%I" ) ) > files.txt

--
HTH, Steve
 
Back
Top