Put path in code? Indesign to PDF

Hi
Here’s a piece of code that makes two types of pdf (Hi-Res and Low-Res) from any Indesign file, selected in the Finder. One thing that I can’t seem to figure out: all files end up on my desktop. I’d like to land them IN A FOLDER on my desktop. Can anyone help me?



tell application "Finder"
	set myfiles to the selection
end tell

tell application "Adobe InDesign CS5"
	activate
	repeat with i in myfiles
		open i
		
		--THIS PRESET NAME SHOULD BE PRESENT IN InDesign!!
		--CHECK: file -> PDF export presets
		set thePreset to "PDF ELS HI-RES"
		
		set theDesk to path to desktop as string
		set f to (name of i as string)
		set thepath to theDesk & f
		
		export document 1 to file (thepath & "_HR.pdf") format PDF type using PDF export preset thePreset without showing options
		
		set thePreset to "[Smallest File Size]"
		
		set theDesk to path to desktop as string
		set f to (name of i as string)
		set thepath to theDesk & f
		
		export document 1 to file (thepath & "_LR.pdf") format PDF type using PDF export preset thePreset without showing options
		
		close active document saving no
	end repeat
end tell

===

Thx

Elszy

Hi,

you haven’t specified a custom folder


.
  set theDesk to (path to desktop as text) & "myFolder:"
.

without any additional code the script assumes that the folder “myFolder” exists.
The trailing colon is important

I doubt, that Indesign can open a Finder file specifier, better write


.
open (i as alias)
.

Thank you Stefan, that works just fine. Exactly what I need, so much obliged!

Elsa

If you want to make sure the user didn’t delete the target folder, put this at the beginning of the script:

tell application "Finder"
	if not (exists folder "myFolder") then
		make new folder at desktop with properties {name:"myFolder"}
	end if
end tell

Great! Thank you!