Script to Export to PDF without .indd suffix

New Here ,
Nov 18, 2020 Nov 18, 2020

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

TOPICS
How to, Scripting

Views

113

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Nov 18, 2020 Nov 18, 2020
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...

Likes

Translate

Translate
Adobe Community Professional ,
Nov 18, 2020 Nov 18, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 19, 2020 Nov 19, 2020

Copy link to clipboard

Copied

Thank you that worked just great.

Now to apply to the rest of the scripts.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 19, 2020 Nov 19, 2020

Copy link to clipboard

Copied

LATEST

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

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines