• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script to Export to PDF without .indd suffix

Community Beginner ,
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

410

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

Community Expert , 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
...

Votes

Translate

Translate
Community Expert ,
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

Votes

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
Community Beginner ,
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.

Votes

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
Community Expert ,
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

 

 

Votes

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