PDA

View Full Version : Automator to create separate pdfs for each folderq




ratboy90
Jan 21, 2012, 10:20 AM
I want to use automator to create a pdf from a set of images each in a separate folder. So folder a - pdf a/folder b - pdf b and so on...

I can't seem to get automator to do this. Can anyone help me out?



TherealDDX
May 27, 2012, 05:33 AM
I need to do exactly the same thing! Any ideas?

telecomm
May 27, 2012, 05:56 AM
You might be able to find something useful in this thread (http://forums.macrumors.com/showthread.php?t=589540).

kryten2
May 27, 2012, 03:26 PM
Try this :


Make Automator worflow with New PDF from Images action. OutputFolder is variable!
Open Script Editor and copy the following script into it. Change the set workflowpath line. Run the script


Caution : No spaces in foldernames or filenames! Couldn't find a solution to that.

-- change line below to the right name and location where you saved your .workflow
set workflowpath to "LeopardFirewire:Users:test:Desktop:New PDF from Images.workflow"
set qtdworkflowpath to quoted form of (POSIX path of workflowpath)
set theExtensionList to {"jpg", "png", "tiff", "pdf"}
set theFolders to choose folder with multiple selections allowed
repeat with aFolder in theFolders
set theInputList to {}
tell application "Finder" to set theFoldersContents to (every item of aFolder whose name extension is in the theExtensionList) as alias list
repeat with anItem in theFoldersContents
set end of theInputList to quoted form of POSIX path of anItem
end repeat
set {tid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, linefeed}
set theInputList to theInputList as text
set AppleScript's text item delimiters to tid
set command to "/usr/bin/automator -v " & "-i '" & theInputList & "' -D OutputFolder=" & quoted form of POSIX path of aFolder & " " & qtdworkflowpath
set output to do shell script command
end repeat
return output


Another script : Spaces in foldernames or filenames allowed

set theFolders to choose folder with multiple selections allowed
repeat with aFolder in theFolders
tell application "Finder"
if not (exists folder "OutputFolder" of aFolder) then
set theOutputfolder to (make new folder at aFolder with properties {name:"OutputFolder"}) as alias
end if
end tell
set command to "cd " & quoted form of POSIX path of aFolder & ";" & "sips -s format pdf *.{jpg,tiff,png,pdf} --out " & "OutputFolder"
set theCombiningPDFcommand to "/System/Library/Automator/Combine\\ PDF\\ Pages.action/Contents/Resources/join.py -o " & quoted form of POSIX path of theOutputfolder & "Combined.pdf" & space & quoted form of POSIX path of theOutputfolder & "*.pdf"
do shell script command
delay 1
do shell script theCombiningPDFcommand
delay 1
tell application "Finder" to delete (every item in folder theOutputfolder whose name is not "Combined.pdf")
tell application "Finder" to empty
end repeat