Hi Statalist,

I don't know enough to be sure, but please let me know if this isn't the right place to be asking this question.

I am trying to merge a series of pdfs saved to a single folder using a tool called pdftk (https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/) that runs from the terminal. To do this, I would like to include in my .do file the following shell commands:

Code:
loc save "/Users/my name/Desktop" 
loc title "title of my document" 

...
putpdf save "`save'/part1_name1.pdf", replace
...
putpdf save "`save'/partN_nameN.pdf", replace


        if c(os) == "MacOSX" {
            !cd "`save'" && pdftk part*.pdf cat output "`title'.pdf"
            !cd "`save'" && rm part*.pdf
        }
        
        if c(os) == "Windows"  {
            !cd "`save'" && pdftk.exe part*.pdf cat output "`title'.pdf"
            !cd "`save'" && del part*.pdf
        }
            
       di "See `save'/`title'.pdf"
This logic functions fine on Windows, but not on Mac. Specifically, when I arrive at the first shell command on a MacOSX, it returns "/bin/bash: pdftk: command not found" while the second shell command successfully erases all files `save'/part*.pdf. This made me think that I had not correctly configured the pdftk package on my Mac, but when I run the same set of commands directly from terminal on Mac, I can successfully merge and erase the pdfs as intended.

Any guidance would be much appreciated.

I am using STATA 15.1 and have macOS High Sierra version 10.13.6. Additionally, I have pdftk 2.02.

Thanks in advance.

Julian