Two Copy-Path related scripts

Below are my first contributions to this forum, so please be considerate, because I’m still a rookie in script-writing. :slight_smile:
There are several “copy a file path” scripts around here, but most of them relates to a previously-selected file in order to work. What I did was simple: just added a navigation window to the script, so the user may now navigate to and select a file s/he wants. Also, I wrote them to work from within FileMaker Pro (above version 4.0), where they can be called through an FMP script at runtime. The script’s redundancy is necessary at this stage; I don’t know the reason, but it helps the Applescript to run better.

So here is the first Applescript:


-- developed by Edward Souza based on several other scripts
-- Copy Path to Clipboard v. 1.3 (c) 2009
on open (path_to)
	set curr_sel to result as alias
	set path_to to (POSIX path of (curr_sel) as string)
	set the_button to button returned of (display dialog path_to buttons {"Cancel", "Copy"} default button 2)
	if the_button is "Copy" then
		set the clipboard to path_to
	end if
end open
on run
	set path_to to (choose file)
	
	set curr_sel to result as alias
	
	set path_to to (POSIX path of (curr_sel) as string)
	
	set the_button to button returned of (display dialog path_to buttons {"Cancel", "Copy"} default button 2)
	if the_button is "Copy" then
		set the clipboard to path_to
	end if
end run

And the second one:


-- developed by Edward Souza based on several other scripts
-- Copy Path to Clipboard v. 1.3 (c) 2009

on open (path_to)
	set curr_sel to result as alias
	set path_to to (POSIX path of (curr_sel) as string)
	set the_button to button returned of (display dialog path_to buttons {"Cancel", "Copy"} default button 2)
	if the_button is "Copy" then
		set the clipboard to path_to
	end if
end open
on run
	set path_to to (choose file)
	
	set curr_sel to result as alias
	
	set path_to to (POSIX path of (curr_sel) as string)
	
	set the_button to button returned of (display dialog path_to buttons {"Cancel", "Copy"} default button 2)
	if the_button is "Copy" then
		set the clipboard to path_to
	end if
	tell application "FileMaker Pro Advanced" -- use only FileMaker Pro, if you are not using the Advanced version
		do script "your_solution's_script_here" -- in here, you write the name of the FileMaker script
	end tell
end run

I’ve devoting some of my time and resources on the communication between FileMaker Pro, the Mac Finder, and other OS X applications. FileMaker is per se a powerful yet simple database RAD; however, when used in conjunction with Applescript, its power raises to a whole new level. Thus in the near future, I’ll be posting more FileMaker-related Applescripts I’m currently working on.
Cheers and happy Applescripting.

Model: 2GHz PowerPC G5 with 2 GB SDRAM
AppleScript: 2.1.2 (81.1)
Browser: Safari 4530.17
Operating System: Mac OS X (10.4)