Avoiding the clipboard

Jun 6, 2009
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.
 

samintz

Scott Mintz
May 20, 2008
1,516
19
Solon, OH, USA
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
 
  • Like
Reactions: hensh

samintz

Scott Mintz
May 20, 2008
1,516
19
Solon, OH, USA
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
 
  • Like
Reactions: hensh
May 20, 2008
11,629
110
Syracuse, NY, USA
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
 
Jun 6, 2009
26
0
No, these are custom pdf documents. The author included a unique ID in the footer of each page.
 
Jun 6, 2009
26
0
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.