Skip to main content
Participant
November 11, 2024
Answered

I too have a script issue with InDesign

  • November 11, 2024
  • 8 replies
  • 659 views

So, in light of of others who have posted about scripts not working since updating to Indesign 2025, I was hoping someone here is far more savy than me could take a look at this script and let mw know how it could be edited to work:

 

tell application "Adobe InDesign 2025"
set doc_name to active document
set doc_pages to every page of doc_name
set file_name to text returned of (display dialog "Please enter a File Name:" default answer "" buttons {"Cancel", "Ok"} default button 2 with icon 1)
set pdf_style to name of every PDF export preset
set export_style to (choose from list pdf_style with prompt "Select PDF Export Preset") as string
set folder_path to (choose folder with prompt "Please select your destination folder...") as string

repeat with anItem in doc_pages
set page_number to name of anItem as string
count characters of page_number
if length of page_number is 1 then
set new_number to text -3 thru -1 of ("00" & page_number)
end if
if length of page_number is 2 then
set new_number to text -3 thru -1 of ("0" & page_number)
end if
if length of page_number is 3 then
set new_number to page_number
end if
if length of page_number is 4 then
set new_number to page_number
end if
set PDF_name to folder_path & new_number & "" & file_name & ".pdf"
set page range of PDF export preferences to page_number
tell doc_name
export format PDF type to PDF_name using export_style without showing options
end tell
end repeat

beep 3
display dialog "Your PDFs were successfully exported" buttons {"Done"} default button 1
end tell

 

Thanks in advance to anyone who can assist!

 

This topic has been closed for replies.
Correct answer leo.r

> set PDF_name to folder_path & new_number & "" & file_name & ".pdf"

 

You have to use (POSIX path of folder_path)

 

Only POSIX paths can be used in InDesign 2025.

8 replies

leo.r
Community Expert
leo.rCommunity ExpertCorrect answer
Community Expert
November 12, 2024

> set PDF_name to folder_path & new_number & "" & file_name & ".pdf"

 

You have to use (POSIX path of folder_path)

 

Only POSIX paths can be used in InDesign 2025.

Legend
November 12, 2024

Little explanation:

The script works on strings instead of the native file classes of AppleScript.

E.g. folder_path is set to the result of choose folder - a folder object - immediately coerced to a string by the as string. This conversion produces a HFS path string (with colons separator) - AppleScript has not changed in that regard.

InDesign itself has changed when it takes a string as alternative to file classes (alias, file, folder), it now interprets the string as posix path.

Short from starting the debugger I would have guessed that the folder_path string has no POSIX path property (along Leo's suggestion). If that becomes a problem, remove the as string, the folder returned by choose folder may have one.

leo.r
Community Expert
Community Expert
November 12, 2024

Just in case: you can get POSIX path of any string:

 

 

Obviously, you need to have a properly formed path in the first place to get a meaningful POSIX path.

Robert at ID-Tasker
Legend
November 11, 2024

What's the problem / error? 

 

Participant
November 11, 2024

This is the line it's indicating it is occuring in:

export format PDF type to PDF_name using export_style without showing options

Robert at ID-Tasker
Legend
November 12, 2024

I'm not Mac user nor AppleScript coder, but what if you add something like this: 

 

display dialog PDF_name

 

right before this line?