Select File Path Script Help Please.

I have a script written for MultiAd Creator that my group uses to send proofs to a folder on the network

On “save” the a script prompts the user to send a PDF proof (yes/no).

If “yes” it creates a PDF and sends it to a specific folder on the network (single file path).

(Script provided below)

What I would like to do is that if “yes” have another prompt/window appear which asks the user to select a destination from a list of names (linked to file path) and then have the end user hit ok at which time the PDF is exported to the select folder.

Or it could be handled first? If “save” then prompt user to select name/path then ok and the file would upload to that path. (if no it just exists the script as does nothing

Its sounds fairly straightforward but its been a very long time since I have worked with script so any help would be greatly appreciated.

I know i have to define the different names/paths ex: dog = file server://10.10.10.10/xxxxx/yyyyyy
but i am not sure where to do it in the script or how to make it display etc. etc etc.

little lost…like i said its been awhile :frowning:

thank you in advance Rick

property PDFPath : “PDFProofs:”

using terms from application “MultiAd Creator Pro”
on saved theDoc
set question to display dialog “Send Proof?” buttons {“Yes”, “No”} default button 2
set answer to button returned of question
if answer is “Yes” then
set fileName to name of theDoc
set destFolder to PDFPath

		--Trim off .crtr extension if it has one:
		if fileName ends with ".crtr" then
			set sd to AppleScript's text item delimiters
			set AppleScript's text item delimiters to {"."}
			set fileName to (text items 1 thru -2 of fileName) as text
			set AppleScript's text item delimiters to sd
		end if
		
		
		tell application "MultiAd Creator Pro"
			
			export PDF current spread of theDoc saving in (destFolder & fileName & ".pdf") print order user order export method composite output color space CMYK stand in resolution 300 black and white compression use zip color image compression use JPEG quality 80 with embed no base 14 fonts, use doc size, binary encoding and compress text and line art without print as spreads, crop marks, registration marks, color bars, document notes, plate information, text blocks only and presentation mode
		end tell
		
		tell application "Finder"
			activate
			tell application "MultiAd Creator Pro"
				activate
			end tell
		end tell
	end if
end saved

end using terms from

Hi.

I’m not familiar with MultiAd Creator Pro, but assuming the syntax for it in your script is correct (although those nested application ‘tell’ statements at the bottom aren’t very nice), here are a couple of possibilities:

  1. Allowing the user a choice of destination and file name, with defaults as per the original script:
property PDFPath : "PDFProofs:"

using terms from application "MultiAd Creator Pro"
	on saved theDoc
		set fileName to name of theDoc
		set destFolder to PDFPath
		
		
		--Trim off .crtr extension if it has one and add a .pdf one:
		if fileName ends with ".crtr" then
			set sd to AppleScript's text item delimiters
			set AppleScript's text item delimiters to {"."}
			set fileName to (text 1 thru text item -2 of fileName)
			set AppleScript's text item delimiters to sd
		end if
		set fileName to fileName & ".pdf"
		
		-- Ask the user to choose a destination and file name, defaults as per the original script. The script will stop if the dialog's Cancel button's clicked.
		set fileReference to (choose file name with prompt "Send proof.?" default location (PDFPath as alias) default name fileName)
		
		tell application "MultiAd Creator Pro"
			
			export PDF current spread of theDoc saving in fileReference print order user order export method composite output color space CMYK stand in resolution 300 black and white compression use zip color image compression use JPEG quality 80 with embed no base 14 fonts, use doc size, binary encoding and compress text and line art without print as spreads, crop marks, registration marks, color bars, document notes, plate information, text blocks only and presentation mode
		end tell
		
		tell application "Finder"
			activate
			tell application "MultiAd Creator Pro"
				activate
			end tell
		end tell
	end saved
end using terms from
  1. To do something similar without allowing the user any influence over the file name, change this .
-- Ask the user to choose a destination and file name, defaults as per the original script. The script will stop if the dialog's Cancel button's clicked.
set fileReference to (choose file name with prompt "Send proof.?" default location (PDFPath as alias) default name fileName)
-- Ask the user to choose a destination, default as per the original script. The script will stop if the dialog's Cancel button's clicked.
set fileReference to (((choose folder with prompt "Send proof? Select a destination folder.." default location (PDFPath as alias)) as text) & fileName) as «class furl»

It would also be possible to present just the names of allowed destinations in a ‘choose from list’ dialog, but obviously I don’t know what names you’d want to allow or how they’d relate to “PDFProofs:” (if they did). If they were all immediate subfolders of “PDFProofs”, the substitution might be something like this:

-- Ask the user to choose from a list of possible destination names. Here, the names of PDFPath's immediate subfolders.
tell application "System Events" to set subfolderNames to name of folders of disk PDFPath whose visible is true
set subfolderChoice to (choose from list subfolderNames with prompt "Send proof? Select a destination folder..")
-- 'choose from list''s Cancel button returns 'false' instead of generating a "User canceled." error, so generate the error here if necessary to stop the script.
if (subfolderChoice is false) then error number -128
-- Othewise, the result is a list containing the chosen name.
set fileReference to (PDFPath & item 1 of subfolderChoice) as «class furl»

By the way, when posting code here, would you mind wrapping it in the [applescript] and [/applescript] tags used by this site so that it’s displayed as above? There’s a button for them just above the message window on posting pages.