Hello I am new to MacScripter so please let me know if there’s anything I should be doing differently.
I am working on modifying an existing script for InDesign. Currently, the script exports each page of the open doc as a PDF with specific naming structure, and it runs a find/replace to get rid of any illegal characters. So now, the department we make the PDFs for would like the name of a linked image (it’s a barcode) to be added to the end of the PDF name. It is possible that the document could be 10 pages long and have a different barcode per page. It is also possible that the document could be 2 pages long, but only have a barcode on the first page“in this case I would want the second page to have something like “NoBarcode” added to the end of the PDF name. The barcode (if there is one) is on it’s own layer for every page. If there is no barcode, then the barcode layer would still exist even though it would be empty.
I’ve been playing around with it for about a week now and can’t get it to look at the link on EACH page’s barcode. I’ve been googling non stop to find new language to try but I am stumped. I’m by no means a pro scripter, and still learning as much as I can.
Any help is GREATLY appreciated. I am really impressed with the community here. Many thanks to anyone with any ideas.
Here is what I have so far (this is just the piece of the script that makes the PDFs). I am using a “Yes” or “No” system just to test if it worked. Eventually I would replace that with the name of the link:
[code]tell app “Adobe InDesign CC 2014”
repeat with myCounter from 1 to (count pages in myDocument)
set myPageName to name of page myCounter of myDocument
set page range of PDF export preferences to name of page myCounter of myDocument
set myBarcodeKey to "Barcode"
set theDocLinks to all graphics of myDocument
repeat with i in theDocLinks
set theLinksLayer to item layer of i
if theLinksLayer contains myBarcodeKey then
set barcodeLayer to layer myBarcodeKey of myDocument
set barcodeList to all graphics of barcodeLayer
repeat with z in barcodeList
set thePage to parent page of z
if thePage is myCounter then
set myBarcode to "Yes"
else
set myBarcode to "No"
end if
end repeat
end if
end repeat
end repeat
end tell[/code]