Create a Dialogue Box to choose part of a file name

Need a little help with the Apple Script below. What the script currently does is, Copies to the Clipboard a selected folder and its Parent folder into a name string which I can then paste into the subject field of an email. However, sometimes I get folder name that is named with two types of Media, eg. PICTURES & MOVIES. At this point I want a dialog box to open and give me a list to pick either Pictures or Movies. Just cant figure out how to do it. Any help would be great.


set giveNameChoice to {"PICTURES & MOVIES"} -- Name of the Folder.
set replaceWith to " create a dialogue box that give an option to pick Pictures or Movies "

tell application "Finder"
	set myTarget to selection as alias
	set nameString to myTarget's name
	set FolderType to nameString's text
	set parentName to myTarget's container's name
	set SubName to parentName & " | " & FolderType & " | on XSAN"
	
	repeat with thisChar in illegalCharacters
		set AppleScript's text item delimiters to {thisChar}
		set newName to text items of SubName
		set AppleScript's text item delimiters to {replaceWith}
		set newName to newName as Unicode text
	end repeat
	
	set the clipboard to newName
end tell

So it looks like I gotten myself a little closer… However with this version, the dialogue box with the List of choices always opens. I would like it to only open when the name of the the selected folder is = “PICTURES & MOVIES”.



property mediaChoice : {"PICTURE(S)", "MOVIE(S)"}

set my_mediaChoice to (choose from list mediaChoice with prompt "Select the name you want to use:" with title "Email Subject Name" with multiple selections allowed and empty selection allowed) as Unicode text



set giveNameChoice to {"PICTURES & MOVIES"} -- Name of the selected folder.
set replaceWith to my_mediaChoice

tell application "Finder"
	set myTarget to selection as alias
	set nameString to myTarget's name
	set FolderType to nameString's text
	set parentName to myTarget's container's name
	set SubName to parentName & " | " & FolderType & " | on XSAN"
	
	
	repeat with thisChar in giveNameChoice
		set AppleScript's text item delimiters to {thisChar}
		set newName to text items of SubName
		set AppleScript's text item delimiters to {replaceWith}
		set newName to newName as Unicode text
	end repeat
	
	set the clipboard to newName
end tell



Looks like i was able to solve my issue with this script. With some help around the web I found the solution.



-- Replaces Underscores with Spaces.
set illegalCharacters to {"_"} -- Whatever you want to eliminate.
set replaceWith to " "

-- Replaces the Word Graphics with GFX
set changeName to {"Graphics"}
set abbrivation to "GFX"

property mediaChoice : {"PICTURE(S)", "MOVIE(S)", "TRAILER(S)", "TV SPOT(S)"} -- Choices in Dialogue list Box
set giveNameChoice to {"PICTURES & MOVIES", "TRAILERS & TV SPOTS"} -- Name of the selected folders that will prompt Dialogue box.


tell application "Finder"
	set myTarget to selection as alias
	set nameString to myTarget's name
	set FolderType to nameString's text
	set parentName to myTarget's container's name
	if nameString is in giveNameChoice then
		
		set my_mediaChoice to (choose from list mediaChoice with prompt "Select the name you want to use:" with title "Email Subject Name" without multiple selections allowed and empty selection allowed) as Unicode text
		
		set removeUnderscores to parentName & " | " & my_mediaChoice & " | on XSAN"
		
		repeat with thisChar in illegalCharacters
			set AppleScript's text item delimiters to {thisChar}
			set newName to text items of removeUnderscores
			set AppleScript's text item delimiters to {replaceWith}
			set newName to newName as Unicode text
		end repeat
		
		set the clipboard to newName
		
	else
		set removeUnderscores to parentName & " | " & FolderType & " | on XSAN"
		
		repeat with thisChar in illegalCharacters
			set AppleScript's text item delimiters to {thisChar}
			set newName to text items of removeUnderscores
			set AppleScript's text item delimiters to {replaceWith}
			set newName to newName as Unicode text
		end repeat
		
		set fixNameGFX to newName
		
		repeat with thisChar in changeName
			set AppleScript's text item delimiters to {thisChar}
			set newName2 to text items of fixNameGFX
			set AppleScript's text item delimiters to {abbrivation}
			set newName2 to newName2 as Unicode text
		end repeat
		
		
		set the clipboard to newName2
		
	end if
	
end tell