• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CS5.5 (Applescript) Packaging and PDF creation script

Community Expert ,
Dec 13, 2012 Dec 13, 2012

Copy link to clipboard

Copied

Hello there.

I have an applescript droplet which, once an InDesign file is dragged onto it, it creates:

  • a High Quality PDF;
  • a Press Quality PDF;
  • a Smallest File Size PDF; and
  • a packaged InDesign file without the instructions.txt.

It's an amazing script but I need it to do one more thing... put the four items into its own folder.

Here is how the script looks so far:

on open mgItems

    repeat with mgThisItem in mgItems

       

        tell application id "com.adobe.InDesign"

            try

                open mgThisItem

                set mgDocName to name of active document

                set text item delimiters of AppleScript to " "

                set mgShortName to text item 1 of mgDocName

                set text item delimiters of AppleScript to ""

                set mgHRFilePath to "Macintosh HD:Users:colly:Desktop:testfolder:" & mgShortName & "_HR.pdf" as string

                set properties of PDF export preferences to properties of PDF export preset "[High Quality Print]"

                tell active document

                    export format PDF type to mgHRFilePath without showing options

                end tell

                set mgHRDigitalFilePath to "Macintosh HD:Users:colly:Desktop:testfolder:" & mgShortName & "_HRD.pdf" as string

                set properties of PDF export preferences to properties of PDF export preset "[Press Quality]"

                tell active document

                    export format PDF type to mgHRDigitalFilePath without showing options

                end tell

                set mgProofFilePath to "Macintosh HD:Users:colly:Desktop:testfolder:" & mgShortName & "_proof.pdf" as string

                set properties of PDF export preferences to properties of PDF export preset "[Smallest File Size]"

                tell active document

                    export format PDF type to mgProofFilePath without showing options

                end tell

                set mgPackageFilePath to "Macintosh HD:Users:colly:Desktop:testfolder:" & mgShortName as string

                tell active document

                    package to mgPackageFilePath with copying fonts, ignore preflight errors, copying profiles, updating graphics, including hidden layers, copying linked graphics and creating report

                end tell

                close active document

            on error

                -- decide what kind of error handling you want to include if the file won't open

            end try

        end tell

       

    end repeat

    display dialog "PDFs created and InDesign file packaged"

end open

As it works at the moment, many indesign files can be dragged onto this droplet, but they all end up in the same folder e.g. upon processing two indesign files, one called namequestion and the other called splash, all files populate the one folder as such:

namequestion.indd

namequestion.indd_HR.pdf

namequestion.indd_HRD.pdf

namequestion.indd_proof.pdf

splash.indd

splash.indd_HR.pdf

splash.indd_HRD.pdf

splash.indd_proof.pdf

what I would like the script to do is put each set of 4 items into their own folders e.g.

namequestion (folder)

   namequestion.indd

   namequestion.indd_HR.pdf

   namequestion.indd_HRD.pdf

   namequestion.indd_proof.pdf

splash (folder)

   splash.indd

   splash.indd_HR.pdf

   splash.indd_HRD.pdf

   splash.indd_proof.pdf

it's probably a rather simple fix but this is my first crack at an applescript... normally play with javascript and still learning all that.

Peter Kahrel has a very good javascript at http://www.kahrel.plus.com/indesign/batch_convert.html  but to get the outcome above (that's how it's been told to be made) Pete's script has to be run four times with much drag and dropping afterwards.

Many thanks

Colin

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!
TOPICS
Scripting

Views

5.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Dec 13, 2012 Dec 13, 2012

Untested but can't you do like this…

property baseFolder : (path to desktop as text) & "exports:"

--

on open mgItems

          repeat with mgThisItem in mgItems

                    tell application id "com.adobe.InDesign"

                              try

  open mgThisItem

                                        set mgDocName to name of active document

                                        set text item delimiters of AppleScript to " "

                                        set mgShortName to text item

...

Votes

Translate

Translate
Guru ,
Dec 13, 2012 Dec 13, 2012

Copy link to clipboard

Copied

You have 2 choices here really… Either AppleScript the Finder To create the required folders and save the files in to these… Or write the script in ExtendScript and have an AppleScript wrapper just call the app's do script method…

edit… where are you dragging files from and where did you want the new folders creating?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 13, 2012 Dec 13, 2012

Copy link to clipboard

Copied

Hi cdflash, try this works fine here using IDCS6 OSX 10.7.4

on open mgItems

    repeat with mgThisItem in mgItems

        tell application id "com.adobe.InDesign"

            try

                open mgThisItem

                set mgDocName to name of active document

                set text item delimiters of AppleScript to " "

                set mgShortName to text item 1 of mgDocName

                set text item delimiters of AppleScript to ""

                set mgShortName to text 1 thru -6 of mgShortName

                tell application "Finder"

                set mgHRFilePath to (make new folder at desktop with properties {name:mgShortName}) as string

                end tell

                -----------------------------------

                --

                -----------------------------------

                set mgShortNameForPDF to mgShortName & "_HR" as string

                set properties of PDF export preferences to properties of PDF export preset "[High Quality Print]"

                tell active document

                    export format PDF type to (mgHRFilePath & mgShortNameForPDF & ".pdf") without showing options

                end tell

                -----------------------------------

                --

                -----------------------------------

                set mgShortNameForPDF to mgShortName & "_HRD" as string

                set properties of PDF export preferences to properties of PDF export preset "[Press Quality]"

                tell active document

                    export format PDF type to (mgHRFilePath & mgShortNameForPDF & ".pdf") without showing options

                end tell

                -----------------------------------

                --

                -----------------------------------

                set mgShortNameForPDF to mgShortName & "_proof" as string

                set properties of PDF export preferences to properties of PDF export preset "[Smallest File Size]"

                tell active document

                    export format PDF type to (mgHRFilePath & mgShortNameForPDF & ".pdf") without showing options

                end tell

                -----------------------------------

                --

                -----------------------------------

                set mgPackageFilePath to mgHRFilePath

                tell active document

                    package to (mgPackageFilePath & mgShortName) with copying fonts, ignore preflight errors, copying profiles, updating graphics, including hidden layers, copying linked graphics and creating report

                end tell

                -----------------------------------

                --

                -----------------------------------

                close active document saving no -- or yes

            on error

                -- decide what kind of error handling you want to include if the file won't open

            end try

        end tell

    end repeat

    activate

    display dialog "PDFs created and InDesign file packaged" giving up after 2

end open

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Dec 13, 2012 Dec 13, 2012

Copy link to clipboard

Copied

You don't need to step in and out of the active document to export each just do it in one…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2012 Dec 13, 2012

Copy link to clipboard

Copied

Ha, ha,

many help for this 😉

did it with just few changes. hope it'll work.

dest will be the folder exports on the desktop.

property baseFolder : (path to desktop as text) & "exports:"

on open mgItems

    repeat with mgThisItem in mgItems

       

        tell application id "com.adobe.InDesign"

            try

                open mgThisItem

                set mgDocName to name of active document

                set text item delimiters of AppleScript to " "

                set mgShortName to text item 1 of mgDocName

                set targetFolderPath to my createFolder(mgShortName)

                set text item delimiters of AppleScript to ""

                set mgHRFilePath to targetFolderPath & mgShortName & "_HR.pdf" as string

                set properties of PDF export preferences to properties of PDF export preset "[High Quality Print]"

                tell active document

                    export format PDF type to mgHRFilePath without showing options

                end tell

                set mgHRDigitalFilePath to targetFolderPath & mgShortName & "_HRD.pdf" as string

                set properties of PDF export preferences to properties of PDF export preset "[Press Quality]"

                tell active document

                    export format PDF type to mgHRDigitalFilePath without showing options

                end tell

                set mgProofFilePath to targetFolderPath & mgShortName & "_proof.pdf" as string

                set properties of PDF export preferences to properties of PDF export preset "[Smallest File Size]"

                tell active document

                    export format PDF type to mgProofFilePath without showing options

                end tell

                set mgPackageFilePath to targetFolderPath & mgShortName as string

                tell active document

                    package to mgPackageFilePath with copying fonts, ignore preflight errors, copying profiles, updating graphics, including hidden layers, copying linked graphics and creating report

                end tell

                close active document

            on error e

                display dialog e

            end try

        end tell

       

    end repeat

    display dialog "PDFs created and InDesign file packaged"

end open

on createFolder(nameString)

    set macFolderPath to baseFolder & nameString

    do shell script "mkdir -p " & quoted form of POSIX path of macFolderPath

    return macFolderPath & ":"

end createFolder

Hans-Gerd Claßen

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Dec 13, 2012 Dec 13, 2012

Copy link to clipboard

Copied

Untested but can't you do like this…

property baseFolder : (path to desktop as text) & "exports:"

--

on open mgItems

          repeat with mgThisItem in mgItems

                    tell application id "com.adobe.InDesign"

                              try

  open mgThisItem

                                        set mgDocName to name of active document

                                        set text item delimiters of AppleScript to " "

                                        set mgShortName to text item 1 of mgDocName

                                        set targetFolderPath to my createFolder(mgShortName)

                                        set text item delimiters of AppleScript to ""

                                        set mgHRFilePath to targetFolderPath & mgShortName & "_HR.pdf" as string

                                        set properties of PDF export preferences to properties of PDF export preset "[High Quality Print]"

                                        tell the active document to export format PDF type to mgHRFilePath without showing options

                                        set mgHRDigitalFilePath to targetFolderPath & mgShortName & "_HRD.pdf" as string

                                        set properties of PDF export preferences to properties of PDF export preset "[Press Quality]"

                                        tell the active document to export format PDF type to mgHRDigitalFilePath without showing options

                                        set mgProofFilePath to targetFolderPath & mgShortName & "_proof.pdf" as string

                                        set properties of PDF export preferences to properties of PDF export preset "[Smallest File Size]"

                                        tell the active document to export format PDF type to mgProofFilePath without showing options

                                        set mgPackageFilePath to targetFolderPath & mgShortName as string

                                        tell the active document to package to mgPackageFilePath with copying fonts, ignore preflight errors, copying profiles, updating graphics, including hidden layers, copying linked graphics and creating report

  close active document

                              on error e

  display dialog e

                              end try

                    end tell

          end repeat

          display dialog "PDFs created and InDesign file packaged"

end open

--

on createFolder(nameString)

          set macFolderPath to baseFolder & nameString

          do shell script "mkdir -p " & quoted form of POSIX path of macFolderPath

          return macFolderPath & ":"

end createFolder

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 13, 2012 Dec 13, 2012

Copy link to clipboard

Copied

very nice, works a treat in cs6, I would just add the below, just to eliminate having to click on the dialog.

close active document saving no --or yes

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 13, 2012 Dec 13, 2012

Copy link to clipboard

Copied

@ Muppet Mark

That was bang-on... nearly. I changed the line:

set text item delimiters of AppleScript to " "

to

set text item delimiters of AppleScript to ".indd"

mainly because of how our jobs are filed. A typical folder will have, for example:

49505 cover.indd

49505 text.indd

49505 endpaper.indd

49505 dust jacket.indd

and running the script purely cut and pasted from this forum would result in the PDFs overwriting, and the indesign files packaging into the same folder.

@ Kevin

I agree, added that line so the "do you want to save" dialog box would not appear.

thank you all very much for your prompt and excellent assistance.

Colin

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 08, 2013 Nov 08, 2013

Copy link to clipboard

Copied

LATEST

Hello guys.

First off sorry to bump quite an old thread, but this thread has been really helpful and the only thing I've found on the internet that has helped me create what I needed.

But I need a little help to perfect the script.

At the minute I have the script doing all the things above, except it only creates two pdfs, the high quality and smallest file size and also exports an .idml.

However the .idml goes into the folder with the pdfs rather than into the packaged files folder, like so:

A7_Test

A7_Test_DownSaved.idml

A7_Test_Packaged

A7_Test_LR.pdf

A7_Test_HR.pdf

I would like .idml  to go into that packaged files folder, I've tinkered around with it but can't get it to work. Can anyone help?

Here's the code:

property baseFolder : (path to desktop as text) & "exports:"

--

on open mgItems

          repeat with mgThisItem in mgItems

                    tell application id "com.adobe.InDesign"

                              try

  open mgThisItem

 

                                        set mgDocName to name of active document

                                        set text item delimiters of AppleScript to ".indd"

                                        set mgShortName to text item 1 of mgDocName

                                        set targetFolderPath to my createFolder(mgShortName)

                                        set text item delimiters of AppleScript to ".indd"

 

                                        set mgHRFilePath to targetFolderPath & mgShortName & "_HR.pdf" as string

                                        set properties of PDF export preferences to properties of PDF export preset "[High Quality Print]"

                                        tell the active document to export format PDF type to mgHRFilePath without showing options

 

                                        set mgProofFilePath to targetFolderPath & mgShortName & "_LR.pdf" as string

                                        set properties of PDF export preferences to properties of PDF export preset "[Smallest File Size]"

                                        tell the active document to export format PDF type to mgProofFilePath without showing options

 

                                        set mgPackageFilePath to targetFolderPath & mgShortName & "_Packaged" as string

                                        tell the active document to package to mgPackageFilePath with copying fonts, ignore preflight errors, copying profiles, updating graphics, including hidden layers, copying linked graphics and creating report

 

                                        set mgIdmlFilePath to targetFolderPath & mgShortName & "_DownSaved.idml" as string

                                        tell the active document to export format InDesign markup to mgIdmlFilePath without showing options

 

  close active document saving no

                              on error e

  display dialog e

                              end try

                    end tell

          end repeat

          display dialog "PDFs created and InDesign file packaged"

end open

--

on createFolder(nameString)

          set macFolderPath to baseFolder & nameString

          do shell script "mkdir -p " & quoted form of POSIX path of macFolderPath

          return macFolderPath & ":"

end createFolder

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2012 Dec 13, 2012

Copy link to clipboard

Copied

Of course,

just did the changes requested ... ;_)

their may be other changes possible too ...

Hans-Gerd Claßen

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines