Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Aouttier

macrumors member
Original poster
Mar 3, 2016
42
0
Belgium
I want to write an AppleScript which combines 2 pdf's. I found on the internet that it can be done with a shell script. But, If my Mac doesn't want to do it. I don't know if I make a mistake in calling the script or if I make a mistake in my filenames (my homedirectory contains spaces). I tried a lot of things, but nothing solved the problem. It drives me nuts!

My current code is:
Code:
tell application "Terminal"
    do shell script "python /System/Library/Automator/Combine\\ PDF\\ Pages.action/Contents/Resources/join.py -o  '/System/Users/Amelie\\ 1\\ 2\\ 3/Desktop/pdf3.pdf' '/System/Users/Amelie\\ 1\\ 2\\ 3/Desktop/pdf1.pdf' '/System/Users/Amelie\\ 1\\ 2\\ 3/Desktop/pdf2.pdf'"
end tell
 

casperes1996

macrumors 604
Jan 26, 2014
7,599
5,771
Horsens, Denmark
First off, you don't actually need the "tell application "Terminal" and "end tell" bits with the "do shell script" command, but there's nothing wrong in having it there either.

So, you escape your spaces with \\. That's perfectly fine. But for the PDF paths you also use '' around the path. You need to do only one or the other. The ''s indicate to bash that the path you've entered is EXACTLY as it should be including the \\ bit, which you don't actually want as part of your path, but only to indicate that there's a space character you don't want bash to interpret.

I think that should fix it all but let me know if there are still problems.

Also, why not just use Automator directly?
 

Aouttier

macrumors member
Original poster
Mar 3, 2016
42
0
Belgium
Now, I have
Code:
do shell script "python /System/Library/Automator/Combine\\ PDF\\ Pages.action/Contents/Resources/join.py -o  /System/Users/Amelie\\ 1\\ 2\\ 3/Desktop/pdf3.pdf /System/Users/Amelie\\ 1\\ 2\\ 3/Desktop/pdf1.pdf /System/Users/Amelie\\ 1\\ 2\\ 3/Desktop/pdf2.pdf"

and it still doesn't work.....het doesn't make the combined pdf.


I've already made an application with automator, but now I'm looking for an AppleScript so I can call it from Filemaker. Or, is there an easy way to call automator from Filemaker?
 

casperes1996

macrumors 604
Jan 26, 2014
7,599
5,771
Horsens, Denmark
Now, I have
Code:
do shell script "python /System/Library/Automator/Combine\\ PDF\\ Pages.action/Contents/Resources/join.py -o  /System/Users/Amelie\\ 1\\ 2\\ 3/Desktop/pdf3.pdf /System/Users/Amelie\\ 1\\ 2\\ 3/Desktop/pdf1.pdf /System/Users/Amelie\\ 1\\ 2\\ 3/Desktop/pdf2.pdf"

and it still doesn't work.....het doesn't make the combined pdf.


I've already made an application with automator, but now I'm looking for an AppleScript so I can call it from Filemaker. Or, is there an easy way to call automator from Filemaker?

Okay, so!

I just teste the command in my own Terminal replacing your user with my own.

First of all, if you have installed Python with Home-brew you can't just use python as your interpreter since that'll link to the brew version which doesn't have the Core Foundation module. You need /usr/bin/python.

Second, why do you start your path with /System?
My Users folder is at the root, so /Users/*
not /System/Users/*

The command did work for me, also in an Apple Script, with the noted caveats.
 

Aouttier

macrumors member
Original poster
Mar 3, 2016
42
0
Belgium
Okay, so!

I just teste the command in my own Terminal replacing your user with my own.

First of all, if you have installed Python with Home-brew you can't just use python as your interpreter since that'll link to the brew version which doesn't have the Core Foundation module. You need /usr/bin/python.

Second, why do you start your path with /System?
My Users folder is at the root, so /Users/*
not /System/Users/*

The command did work for me, also in an Apple Script, with the noted caveats.


Thank you! It works! After trying for a week...

It was the second advice, which was the correct one. Apparently, he didn't find the files.

Tanks a lot!
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.