Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Create And Combine PDF and Rename Them Based of Containing Folder

Ok, here is the situation, I have alot of photographs in seperate folders that I would like to make them into pdf files. I am looking for a way to use Apple Script or Automator (or both) to create pdf files out of jpg images, combine them into one pdf file, and then have the pdf file rename based off of the folder in witch the orginial photographs were in. Bascially it is like this...


I would like to take these folders


Folder: Family Summer Vacation

Folder Contents: image 001.jpg, image 002.jpg, etc...

Folder: Family Chrstmas

Folder Contents: Christmas 1.jpg, Chirstmas 2.jpg, etc...

(there are many more folders)


Results afterwords..


Family Sumer Vacation.pdf

Family Christmas.pdf


Now the thing is that I do not want to do these one at a time. Is there a way I can use automator or Applescript to select several folders at once to make the pdf files?


I have tried to look online for solutions but most of the answeres only went half way...

To create mutiple PDF files, did come across a program for automotar that did this....

-Get Selected Finder Items

-Dispense Items Incrementally

-Set Value of Variable (Storage)

-Get Folder Contents

-New PDF From Images

-Loop


This works merging the JPG files into a single PDF file. However, the problem is that it does not name pdfs file off of the folders from which they came. I apperciate the help :-)

MacBook Pro (15-inch Late 2011), Mac OS X (10.7.5)

Posted on Feb 3, 2013 7:55 PM

Reply
Question marked as Best reply

Posted on Feb 10, 2013 2:43 AM

It's a bit of a trick, but the way I'd do this is to call an automator workflow inside an applescript loop. First you set up a workflow that looks like this (save it somewhere convenient):


User uploaded file

Note carefully the two variables - NewName and FolderPath - and how they are used in the various actions. FolderPath is a path variable, NewName a text variable, and it's important that they get set up correctly, because that's how we get info into the workflow.


Once that's made and saved, copy the path to the workflow into the first line of the following script, run it in the applescript editor, and you should be good to go. (one note - it won't overwrite pdf files of the same name, so you might end up with duplicate files - filename 2. pdf, filename 3.pdf - if you run it on the same folder(s) a few times).


set workflow_path to "'/path/to/workflow.workflow'"


choose folder with multiple selections allowed

set the folder_list to the result


repeat with this_folder in the folder_list



-- get name and posix path of a folder

tell application "System Events"

set the folder_name to the name of this_folder

set the folder_path to POSIX path of this_folder

end tell



-- call automator workflow to process pdfs

do shell script "automator -D NewName=" & quoted form of folder_name & " -D FolderPath=" & quoted form of folder_path & " " & workflow_path


end repeat

1 reply
Question marked as Best reply

Feb 10, 2013 2:43 AM in response to Elosan

It's a bit of a trick, but the way I'd do this is to call an automator workflow inside an applescript loop. First you set up a workflow that looks like this (save it somewhere convenient):


User uploaded file

Note carefully the two variables - NewName and FolderPath - and how they are used in the various actions. FolderPath is a path variable, NewName a text variable, and it's important that they get set up correctly, because that's how we get info into the workflow.


Once that's made and saved, copy the path to the workflow into the first line of the following script, run it in the applescript editor, and you should be good to go. (one note - it won't overwrite pdf files of the same name, so you might end up with duplicate files - filename 2. pdf, filename 3.pdf - if you run it on the same folder(s) a few times).


set workflow_path to "'/path/to/workflow.workflow'"


choose folder with multiple selections allowed

set the folder_list to the result


repeat with this_folder in the folder_list



-- get name and posix path of a folder

tell application "System Events"

set the folder_name to the name of this_folder

set the folder_path to POSIX path of this_folder

end tell



-- call automator workflow to process pdfs

do shell script "automator -D NewName=" & quoted form of folder_name & " -D FolderPath=" & quoted form of folder_path & " " & workflow_path


end repeat

Create And Combine PDF and Rename Them Based of Containing Folder

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.