Kick names, take ass.

4-28-2006 6:51 pm
David: How to...
Automate the cleanup and organization of job folders, while at the same time generating a high resolution PDF from an InDesign file. And some other stuff.

Oh, and it's in Applescript, that way Windows users can't use it. Why? Because I'm too lazy to worry about Java.

tell application "Adobe InDesign CS2"
activate
set thisDocument to active document
set AdFolder to file path of thisDocument as alias
set ExistingOrganize to AdFolder as text
set DoomedFile to name of thisDocument as text
tell thisDocument
set TotalLinks to count of links
end tell
end tell
tell application "Finder"
if ExistingOrganize contains "_Document" then
set OrganizeOrNot to "Not" as text
else
set OrganizeOrNot to "Organize" as text
end if
end tell
if OrganizeOrNot is "Organize" then
tell application "Finder"
activate
set DocName to name of AdFolder as text
set AdFolder to AdFolder as text
set SupportFolder to make new folder in folder AdFolder with properties {name:"_Support Files"}
set SupportFolder to SupportFolder as text
move (items in folder AdFolder where name is not "_Support Files" and name is not "_Fonts") to folder SupportFolder
set LinksFolder to make new folder in folder AdFolder with properties {name:"_Links"}
set LinksFolder to LinksFolder as text
set DocumentFolder to make new folder in folder AdFolder with properties {name:"_Document"}
set DocumentFolder to DocumentFolder as text
repeat with i from 1 to TotalLinks
tell application "Adobe InDesign CS2"
activate
tell thisDocument
set thisLink to link i
set LinkName to name of thisLink
set LinkPath to SupportFolder&LinkName
end tell
end tell
tell application "Finder"
move file LinkPath to folder LinksFolder
set FinalLink to LinksFolder&LinkName
end tell
tell application "Adobe InDesign CS2"
tell thisDocument
relink thisLink to FinalLink
end tell
end tell
end repeat
end tell
tell application "Adobe InDesign CS2"
set myDocument to active document
tell myDocument
--Get page information
set myPageTotal to pages per document of document preferences
set myPageHeight to page height of document preferences
set myPageWidth to page width of document preferences
--Set print preset
tell print preferences of myDocument
set printer to postscript file
set PPD to "Prinergy Refiner"
--General
set reverse order to false
set print spreads to false
set print master pages to false
set print nonprinting to false
set print blank pages to true
--Setup
set paper size to custom
set print page orientation to portrait
set paper height to myPageHeight + 1
set paper width to myPageWidth + 1
set paper offset to 0
set paper gap to 0
set paper transverse to false
set scale mode to scale width height
set scale width to 100
set scale height to 100
set scale proportional to true
set page position to centered
set thumbnails to false
set tile to false
--Marks and Bleed
set crop marks to true
set registration marks to true
set bleed marks to false
set color bars to false
set page information marks to false
set mark type to default
set mark line weight to p25pt
set mark offset to "0.1667 in"
set use document bleed to print to false
set bleed top to "0.125 in"
set bleed inside to "0.125 in"
set bleed bottom to "0.125 in"
set bleed outside to "0.125 in"
set include slug to print to false
--Output
set color output to composite CMYK
set flip to none
set simulate overprint to false
--Graphics
set send image data to optimized subsampling
set font downloading to complete
set PostScript level to level 3
set data format to ASCII
set download PPD fonts to true
--Advanced
set OPI image replacement to false
set omit EPS to false
set omit PDF to false
set omit bitmaps to false
set flattener preset name to "[High Resolution]"
set ignore spread overrides to false
end tell
set FullOrNot to button returned of (display dialog "Is this a full page ad?" buttons {"Yes", "No"} default button "No")
if FullOrNot is "Yes" then
set JobNumber to (display dialog "Enter your 5 digit job number" default answer "")
set JobNumber to (text returned of result)
set DocName to JobNumber&" "&DocName
else if FullOrNot is "No" then
set DocName to DocName as text
end if
set DocPath to DocumentFolder&DocName
save myDocument to DocPath
end tell
set myFileName to my myReplace(DocName, ".indd", "")
tell application "Adobe InDesign CS2"
set myDocument to active document
tell myDocument
set myFullName to AdFolder&myFileName&".ps"
tell print preferences of myDocument
set print file to myFullName
end tell
print myFullName without print dialog
end tell
end tell
end tell
set myPDFName to my myReplace(myFullName, ".ps", ".pdf")
set myErrorName to my myReplace(myFullName, ".ps", ".log")
tell application "Finder"
if file myPDFName exists then delete file myPDFName
if file myErrorName exists then delete file myErrorName
repeat until file myFullName exists
delay 5
end repeat
end tell
tell application "Adobe InDesign CS2"
close myDocument saving yes
end tell
tell application "Acrobat Distiller 7.0"
activate
open myFullName
end tell
tell application "Finder"
repeat until (file myPDFName exists) or (file myErrorName exists)
delay 5
end repeat
delete file myFullName
end tell
if myPDFName exists then
set myPDF to myPDFName as alias
tell application "Adobe Acrobat 7.0 Pro#D8C5B"
activate
open myPDF
end tell
else if myErrorName exists then
display dialog "The PostScript file failed to generate a PDF"
end if
tell application "Finder"
try
set DoomedFile to SupportFolder&DoomedFile
delete file DoomedFile
end try
end tell
else if OrganizeOrNot is "Not" then
tell application "Adobe InDesign CS2"
activate
set myDocument to active document
tell myDocument
--Get page information
set myPageTotal to pages per document of document preferences
set myPageHeight to page height of document preferences
set myPageWidth to page width of document preferences
--Set print preset
tell print preferences of myDocument
set printer to postscript file
set PPD to "Prinergy Refiner"
--General
set reverse order to false
set print spreads to false
set print master pages to false
set print nonprinting to false
set print blank pages to true
--Setup
set paper size to custom
set print page orientation to portrait
set paper height to myPageHeight + 1
set paper width to myPageWidth + 1
set paper offset to 0
set paper gap to 0
set paper transverse to false
set scale mode to scale width height
set scale width to 100
set scale height to 100
set scale proportional to true
set page position to centered
set thumbnails to false
set tile to false
--Marks and Bleed
set crop marks to true
set registration marks to true
set bleed marks to false
set color bars to false
set page information marks to false
set mark type to default
set mark line weight to p25pt
set mark offset to "0.1667 in"
set use document bleed to print to false
set bleed top to "0.125 in"
set bleed inside to "0.125 in"
set bleed bottom to "0.125 in"
set bleed outside to "0.125 in"
set include slug to print to false
--Output
set color output to composite CMYK
set flip to none
set simulate overprint to false
--Graphics
set send image data to optimized subsampling
set font downloading to complete
set PostScript level to level 3
set data format to ASCII
set download PPD fonts to true
--Advanced
set OPI image replacement to false
set omit EPS to false
set omit PDF to false
set omit bitmaps to false
set flattener preset name to "[High Resolution]"
set ignore spread overrides to false
end tell
save myDocument
end tell
set myDocument to active document
set myFilePath to file path of myDocument as string
set PDFFilePath to my myReplace(myFilePath, "_Document:", "")
set myFileName to name of myDocument as string
set myFileName to my myReplace(myFileName, ".indd", "")
tell application "Adobe InDesign CS2"
tell myDocument
set myFullName to PDFFilePath&myFileName&".ps"
tell print preferences of myDocument
set print file to myFullName
end tell
print myFullName without print dialog
end tell
end tell
end tell
set myPDFName to my myReplace(myFullName, ".ps", ".pdf")
set myErrorName to my myReplace(myFullName, ".ps", ".log")
tell application "Finder"
if file myPDFName exists then delete file myPDFName
if file myErrorName exists then delete file myErrorName
repeat until file myFullName exists
delay 5
end repeat
end tell
tell application "Adobe InDesign CS2"
close myDocument saving yes
end tell
tell application "Acrobat Distiller 7.0"
activate
open myFullName
end tell
tell application "Finder"
repeat until (file myPDFName exists) or (file myErrorName exists)
delay 5
end repeat
delete file myFullName
end tell
if myPDFName exists then
set myPDF to myPDFName as alias
tell application "Adobe Acrobat 7.0 Pro#D8C5B"
activate
open myPDF
end tell
else if myErrorName exists then
display dialog "The PostScript file failed to generate a PDF"
end if
tell application "Finder"
try
set DoomedFile to SupportFolder&DoomedFile
delete file DoomedFile
end try
end tell
end if
on myReplace(myString, myFindString, myChangeString)
set AppleScript's text item delimiters to myFindString
set myTextList to every text item of (myString as text)
set AppleScript's text item delimiters to myChangeString
set myString to myTextList as string
set AppleScript's text item delimiters to ""
return myString
end myReplace



Thankful: I'm not a programmer



Your account has been disabled. 
Log In
Username:

Password:

Public Terminal

 
Lyric
Komm, gib mir deine Hand
 
User Journals
Your Hosts
Links