Help Tweaking a Script

I have mucked about making this script for inDesign and have it pretty close to what I want except that the resulting files are named “filename.indd_press.pdf” which is just ugly. Can this be reworked so that it drops the “.indd” or replaces it with “_press.pdf”??


--simple script that writes the PDF and JPG files in the same location as the Indesign file

tell application "InDesign CS"
	tell active document
		set docName to full name as Unicode text
		export format PDF type to docName & "_press" & ".pdf" using "PRESS2" without showing options
	end tell
	tell active document
		set docName to full name as Unicode text
		export format PDF type to docName & "_screen" & ".pdf" using "[Screen]" without showing options
	end tell
	tell active document
		set myjpg to full name as Unicode text
		export format JPG to myjpg & ".jpg"
	end tell
end tell

I don’t have InDesign so I can’t tweak your script directly, but this should give you some ideas:

set myName to "thisIsMyFile.indd"

set clipPoint to offset of ".indd" in myName
set trimmedName to (characters 1 thru (clipPoint - 1) of myName) as string
set outputName to trimmedName & "_press" & ".pdf"

display dialog outputName

I tried various ways of using the code you provided and can get it to display the name (the whole path) but when that code is in there it won’t output the file now. Maybe I could rename the file after it creates it. What do you think?

I’ve kind of had to do the same thing before. I worked with the Finder to accomplish this. First, get the file you want, and then set the extension visible to false. Then set a variable to the displayed name of the file. This will give you the name of the file without the extension. Then you can use it to name your other files. It’s been a while since I did this, so I don’t remember the exact syntax, but that is what I basically did.