The following script will activate/deactivate layers based on the letter {A,E,D, F} chosen from the list.
The problem I have I don’t know how to rename the pdf based on the letter chosen from the list.
If file name is ABC01_A100.indd & the letter chosen from the list is E then final pdf should be ABC01E100.pdf. Basically what is changing whatever is between the underscores ?
If the letter chosen from the list is D then final pdf is ABCD_100.pdf. I can see the results on the events window. How can I capture the results of whatever is chosen from list? I try return statement but no success at all.
Text item delimiters have been always a very difficult concept for me to grasp. I always try to understand it but as simple as that I can’t.
¢Then if i use choose from list with multiple selection allowed in which I can select more letters: A", “E”, “D”, “F” how can I output different PDFs with whatever is chosen from the list (with the correct layers activated/deactivated) & file names; ABC01_E100.pdf, ABC01F100.pdf, ABC01F_100.pdf. I know it is not difficult but after spending 4 days trying to figure it out by myself reading, researching I have to throw the towel & ask for help at this forum.
property myPDFpreset : missing value
set myPDFpreset to "PressQuality"
tell application "Adobe InDesign CS4"
if not (exists document 1) then
display alert "Please open an InDesign document"
error number -128
end if
end tell
set versionLayers to {"A", "E", "D", "F"}
set the_choice to (choose from list versionLayers with prompt "What version do you need?" without multiple selections allowed) as text
set chosenVersionLayer to item 1 of the_choice
-->Activate versions Layers
if the_choice is false then error number -128
if the_choice is "A" then
myAB()
else if the_choice is "E" then
myE()
else if the_choice is "D" then
myD()
else if the_choice is "F" then
myF()
end if
on myA()
tell application "Adobe InDesign CS4"
--set myDocument to active document
tell active document
--Activate Layers
set properties of layer "Tive" to {visible:true}
set properties of layer "Logo" to {visible:true}
set properties of layer "Search" to {visible:true}
set properties of layer "Z1" to {visible:true}
--Hide Layers
set properties of layer "Z2" to {visible:false}
set properties of layer "Z3" to {visible:false}
set properties of layer "GS" to {visible:false}
set properties of layer "BD" to {visible:false}
end tell
display alert "Version AB activated" giving up after 6
end tell
end myA
on myE()
tell application "Adobe InDesign CS4"
--set myDocument to active document
tell active document
--Activate Layers
set properties of layer "Tive" to {visible:true}
set properties of layer "Logo" to {visible:true}
set properties of layer "Search" to {visible:true}
set properties of layer "Z2" to {visible:true}
--Hide Layers
set properties of layer "Z1" to {visible:false}
set properties of layer "Z3" to {visible:false}
set properties of layer "GS" to {visible:false}
set properties of layer "BD" to {visible:false}
end tell
display alert "Version E activated" giving up after 6
end tell
end myE
on myD()
tell application "Adobe InDesign CS4"
--set myDocument to active document
tell active document
--Activate Layers
set properties of layer "Tive" to {visible:true}
set properties of layer "Logo" to {visible:true}
set properties of layer "Z3" to {visible:true}
--Hide Layers
set properties of layer "Z1" to {visible:false}
set properties of layer "Z2" to {visible:false}
set properties of layer "GS" to {visible:false}
set properties of layer "BD" to {visible:false}
set properties of layer "Search" to {visible:false}
end tell
display alert "Version D activated" giving up after 6
end tell
end myD
on myF()
tell application "Adobe InDesign CS4"
--set myDocument to active document
tell active document
--Activate Layers
set properties of layer "Tive" to {visible:true}
set properties of layer "Logo" to {visible:true}
set properties of layer "Z3" to {visible:true}
set properties of layer "GS" to {visible:true}
--Hide Layers
set properties of layer "Z1" to {visible:false}
set properties of layer "Z2" to {visible:false}
set properties of layer "BD" to {visible:false}
set properties of layer "Search" to {visible:false}
end tell
display alert "Version F activated" giving up after 6
end tell
end myF
---======================
tell application "Adobe InDesign CS4"
activate
set source_folder to file path of active document --Put the PDFs same folder as ID file
set theName to name of active document
set text item delimiters of AppleScript to {"_"}
set theShortName to text 1 thru text item -2 of theName
--text 1 thru text item -2 is every character from the first character to the second to last text item
set text item delimiters of AppleScript to ""
tell application "Finder"
if (exists folder "PDFs" of folder source_folder) is false then
make folder at source_folder with properties {name:"PDFs"}
end if
end tell
repeat with x from 1 to count pages of active document
set thePageName to name of page x of active document
set page range of PDF export preferences to thePageName
--section-page number M-U-S-T have 3 digits
set threeDigitPageName to text -3 thru -1 of ("00" & thePageName)
(* text 1 thru 3 are the first 3 characters
text -3 thru -1 are the last 3 characters*)
set theFilePath to source_folder & "PDFs:" & theShortName & "_" & threeDigitPageName & ".pdf" as string
----Export PDF as single pages
tell active document
export format PDF type to theFilePath using myPDFpreset without showing options
end tell
end repeat
end tell
set versionLayers to {"A", "E", "D", "F"}
set the_choice to (choose from list versionLayers with prompt "What version do you need?" with multiple selections allowed) as text
set chosenVersionLayer to item 1 of the_choice
--export PDFS with items selected from list