Selected Items path

Hi, I 've looked around and cannot find the answer to this.

What I would like to happen is the following: I select an item (folder or file) in the finder and run an applescript that then records the location of that item. The script would hold on to that location untill I tell it otherwise via a prompt or such.

This would get me started in my project but I’m not having much luck.

I’m not sure I follow you completely, but this script will get the path of the selected item in the Finder…

tell application "Finder"
	activate
	set selectedItems to (get selection)
	set pathList to ""
	repeat with singleItem in selectedItems
		if pathList is "" then
			set pathList to (singleItem as text)
		else
			set pathList to pathList & return & (singleItem as text)
		end if
	end repeat
	set the clipboard to pathList
	pathList
end tell

Hi :slight_smile:
With this small suggestion, you can know the path of the items selected (like the script of Greg ;)), and also those which you will deposit on the icon of script (drag & drop) when de script is stored as application (droplet) :

on run
	tell application "Finder" to {me, selection} as alias list
	open (rest of result) of me
end run

on open Lst
	set text item delimiters of AppleScript to return
	set the clipboard to ("" & Lst)
	set text item delimiters of AppleScript to ""
end open

Tested with Os 9 and AS 1.4 :smiley:

Fredo’s script works in Mac OS X 10.2.8 with AppleScript 1.9.1

PS: I did not write the script in my above reply. I’m not sure of the Authors name, so credit goes to who every ye may be.

Ho… Thank you Greg for the test :smiley:

But, unfortunately, my script return an error when no item is selected, then, here a small correction :

on run
	tell application "Finder" to {me, selection} as alias list
	open (rest of result) of me
end run

on open Lst
	set text item delimiters of AppleScript to return
	if (count ({} & (item 1 of Lst))) > 0 then set the clipboard to ("" & Lst)
	set text item delimiters of AppleScript to ""
end open

:wink: