Welcome!

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

SignUp Now!

Avoiding the clipboard

Jun
26
0
The following code works like a charm, but I wonder if there is there another (better) way to feed the captured TPIPE string to the rename command?

Code:
rem Rename generic PDFs with internal page ID found in the PDF.
do f in p*.pdf
  tpipe /input=%f /output=CLIP: /simple=76 /grep=3,0,0,0,0,0,0,0,ID
  ren /Q %f %@regexsub[1,(\d+),%@clip[0]].pdf
enddo

I know I can use redirection but I'd like to do something like /output=idVariable. However, that doesn't work.
 
You could use nested DO loops. Try this:
Code:
rem Rename generic PDFs with internal page ID found in the PDF.
do p in p*.pdf
  do f in /p  tpipe /input=%p /simple=76 /grep=3,0,0,0,0,0,0,0,ID (ren /Q %p %@regexsub[1,(\d+),%f].pdf)
enddo
 
Or alternatively, you can use @execstr[] to capture the tpipe output.
Code:
rem Rename generic PDFs with internal page ID found in the PDF.
do f in p*.pdf
    ren /Q %f %@regexsub[1,(\d+),%@execstr[tpipe /input=%f /simple=76 /grep=3,0,0,0,0,0,0,0,ID]].pdf  
enddo
 
I just wanted to see it work so I tried it on the PDFs below. I got nothing from the first three and only "DEV ID:" from the last one. Do PDFs in general have an "ID"? Are you looking at only a special collection of PDFs?

Code:
census2020.pdf
Recycling101.pdf
SatPuz12052020.pdf
Verizon_Receipt.pdf
 
You could use nested DO loops. Try this:
Code:
rem Rename generic PDFs with internal page ID found in the PDF.
do p in p*.pdf
  do f in /p  tpipe /input=%p /simple=76 /grep=3,0,0,0,0,0,0,0,ID (ren /Q %p %@regexsub[1,(\d+),%f].pdf)
enddo
This is what I was looking for. Not sure how I missed /p in the docs. Thanks.
 
Back
Top