Automator to create separate pdfs for each folderq

Discussion in 'Mac Programming' started by ratboy90, Jan 21, 2012.

  1. macrumors 6502

    ratboy90

    Joined:
    Apr 15, 2009
    #1
    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?
     
  2. macrumors member

    Joined:
    Oct 14, 2008
    Location:
    Prague, Czech Republic
    #2
    I need to do exactly the same thing! Any ideas?
     
  3. macrumors 65816

    telecomm

    Joined:
    Nov 30, 2003
    Location:
    Rome
    #3
    You might be able to find something useful in this thread.
     
  4. kryten2, May 27, 2012
    Last edited: May 28, 2012

    macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #4
    Try this :

    1. Make Automator worflow with New PDF from Images action. OutputFolder is variable!
    2. 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.

    Code:
    -- 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

    Code:
    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
     

    Attached Files:

Share This Page