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

The JTizzle

macrumors 6502
Original poster
Jun 14, 2009
316
39
Maine
I'm super desperate and hoping someone can help me. I need a folder action so when I drop a numbers file into the folder it converts it to a PDF and junks the numbers doc. Can anyone share or make me this? Been trying to make one myself but just can;'t get it to work :(
 

mikew99

macrumors newbie
Sep 15, 2016
5
0
I'm super desperate and hoping someone can help me. I need a folder action so when I drop a numbers file into the folder it converts it to a PDF and junks the numbers doc. Can anyone share or make me this? Been trying to make one myself but just can;'t get it to work :(

This seems to work, but will export the PDF to your desktop.

on adding folder items to this_folder after receiving added_items
repeat with this_file in added_items
tell application "Finder"
set theInfo to properties of this_file
set theName to name of theInfo
set theName to (characters 1 through -9) of theName as text
set thePath to desktop as string
end tell

tell application "Numbers"
activate
open this_file
set thisDoc to document 1
export thisDoc to file (thePath & theName & ".pdf" as string) as PDF
quit
end tell


tell application "Finder"
delete this_file
end tell

end repeat
end adding folder items to
 
Last edited:

The JTizzle

macrumors 6502
Original poster
Jun 14, 2009
316
39
Maine
This seems to work, but will export the PDF to your desktop.

on adding folder items to this_folder after receiving added_items
repeat with this_file in added_items
tell application "Finder"
set theInfo to properties of this_file
set theName to name of theInfo
set theName to (characters 1 through -9) of theName as text
set thePath to desktop as string
end tell

tell application "Numbers"
activate
open this_file
set thisDoc to document 1
export thisDoc to file (thePath & theName & ".pdf" as string) as PDF
quit
end tell


tell application "Finder"
delete this_file
end tell

end repeat
end adding folder items to


Ok tried it and this is almost perfect, can you explain what I can change to edit the final location of the PDF so stays in the folder that with the folder action? (which is a dropbox folder)
 
Last edited:

mikew99

macrumors newbie
Sep 15, 2016
5
0
Ok tried it and this is almost perfect, can you explain what I can change to edit the final location of the PDF?

You could make a folder on your desktop and have it exported to that location. For instance, you could create a folder named "Exported PDF" that resides on your desktop. Then what you would want to do is change the path to direct to that folder. In my example, thePath is the desktop folder. You could change that one line in the script to:

set thePath to folder "Exported PDF" of desktop as string
 

The JTizzle

macrumors 6502
Original poster
Jun 14, 2009
316
39
Maine
How would you write a path to something other than the desktop? such as ~/Dropbox/Folder 1 ? I understand the concept, just can't get it to work with the proper edit
 

mikew99

macrumors newbie
Sep 15, 2016
5
0
How would you write a path to something other than the desktop? such as ~/Dropbox/Folder 1 ? I understand the concept, just can't get it to work with the proper edit
One thing you could do is open Script Editor and run this:

tell application "Finder"
set theFolder to choose folder
end tell

Whatever the result is, just copy that and set thePath to your result.
 

The JTizzle

macrumors 6502
Original poster
Jun 14, 2009
316
39
Maine
Oh thats perfect, I got it. THANKS A TON!!!!!!!!!!!!!!!!! If you ever need a design favor hit me up, I owe you one man!
 

mikew99

macrumors newbie
Sep 15, 2016
5
0
You'd kind of end up with the line looking something like this:

set thePath to folder "Macintosh HD:Users:User:Dropbox:Folder 1:" as string
[doublepost=1474045746][/doublepost]You're welcome, sir. Have a good one.
 

The JTizzle

macrumors 6502
Original poster
Jun 14, 2009
316
39
Maine
sorry one last question, will this overwrite a old PDF file if a new one is created with the same name? Or do I need to add something to get that to work?
 

mikew99

macrumors newbie
Sep 15, 2016
5
0
sorry one last question, will this overwrite a old PDF file if a new one is created with the same name? Or do I need to add something to get that to work?
Yes, I think that it will overwrite the existing file in that Dropbox folder. Let me test it out and I will let you know.
[doublepost=1474048051][/doublepost]Are your numbers documents NOT going to have unique names? If each numbers document has a unique name, then it won't be an issue.
 

The JTizzle

macrumors 6502
Original poster
Jun 14, 2009
316
39
Maine
Sorry was a busy day. The overwrite works flawlessly, tested it a few times. The one last issue I seem to have is after testing is I put the numbers files in the folder, it does the conversion, junks the numbers but then tries to run the conversion again on the newly created PDF since I am using the conversion folder as the destination folder. Is there something I can add to make it ignore PDF file types? We lock that in and its flawless!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.