Copy link to clipboard
Copied
I use this script to export 2 different PDF's to the desktop. Naming one with 'X' at the end and then change the tag colour for each.
I would like the PDF's to export without the '.indd' in the file name. When outputting in InDesign there is an option to stop this, but it doesn't work in the script. Everything works great with the script, just want to remove the.indd from the PDF filename.
Thank you for your help.
tell application "Adobe InDesign 2021"
set _NoCrops to PDF export preset "No Crops"
set _Crops to PDF export preset "Crop NO Text"
set _dest to path to desktop as string
set _Name to name of active document as string
tell active document
export format PDF type to (_dest & _Name & " X" & ".pdf") using _NoCrops without showing options
export format PDF type to (_dest & _Name & ".pdf") using _Crops without showing options
delay 2
tell application "Finder"
set the_file to (_dest & _Name & " X" & ".pdf") select
tell application "Finder"
set label index of document file (_dest & _Name & " X" & ".pdf") to 7
tell application "Finder"
set the_file to (_dest & _Name & ".pdf") select
tell application "Finder"
set label index of document file (_dest & _Name & ".pdf") to 2
close window 1
end tell
end tell
end tell
end tell
end tell
end tell
Try this:
tell application id "com.adobe.indesign"
set _NoCrops to PDF export preset "No Crops"
set _Crops to PDF export preset "Crop NO Text"
set _dest to path to desktop as string
tell active document
set _Name to name
if _Name ends with ".indd" then
set _Name to text 1 thru -6 of _Name
end if
set noCropPath to _dest & _Name & " X" & ".pdf"
set cropPath to _dest & _Name & ".pdf"
export format PDF type to noCropPath using _NoCrops without showing options
export format P
...
Copy link to clipboard
Copied
Try this:
tell application id "com.adobe.indesign"
set _NoCrops to PDF export preset "No Crops"
set _Crops to PDF export preset "Crop NO Text"
set _dest to path to desktop as string
tell active document
set _Name to name
if _Name ends with ".indd" then
set _Name to text 1 thru -6 of _Name
end if
set noCropPath to _dest & _Name & " X" & ".pdf"
set cropPath to _dest & _Name & ".pdf"
export format PDF type to noCropPath using _NoCrops without showing options
export format PDF type to cropPath using _Crops without showing options
end tell
end tell
tell application "Finder"
set label index of file noCropPath to 7
set label index of file cropPath to 2
end tell
Copy link to clipboard
Copied
Thank you that worked just great.
Now to apply to the rest of the scripts.
Copy link to clipboard
Copied
You can wrap the if statement in a handler, which would let you get the file name with one line in the main code. Something like this:
tell application id "com.adobe.indesign"
tell active document
set _Name to my getName(name)
end tell
end tell
--returns the file name with no extension
on getName(n)
if n ends with ".indd" then
set n to text 1 thru -6 of _Name
end if
return n
end getName