Re: How to convert Finder reference?
Re: How to convert Finder reference?
- Subject: Re: How to convert Finder reference?
- From: Gary Lists <email@hidden>
- Date: Fri, 12 Dec 2003 00:19:56 -0500
- Http: //bau2.uibk.ac.at/sg/python/Sounds/HolyGrail.wav/taunt.wav
On Dec 11, 2003, at 2:52 PM, Mark Dawson wrote:
>
> I want to convert a Finder reference to a string
>
> (duplicate x; set z to the result as string)
On or about 12-11-03 5:25 PM, Michelle Steiner wrote:
>
This works for me:
>
>
tell application "Finder"
>
set x to item 1 of (the selection as list)
>
duplicate x
>
set z to the result as string
>
[ --> -- "My iMac:Desktop Folder:test copy" ]
>
end tell
On or about 12-11-03 8:46 PM, John W. Baxter wrote:
>
document file "2003Winter.pdf" of desktop of application "Finder" as string
>
>
-->"Blake:Users:john:Desktop:2003Winter.pdf"
I gathered that Mark wanted to (for some reason) convert a finder reference
into its _string equivalent_ ...?
If so, Mark, did you know that there are more efficient ways of
"referencing" a file than using a "finder reference"?
Or did you really mean you wanted a string equivalent of said reference?
Or did three people already answer in a way you could use? ;)
Since all this 'bonus' and 'extra credit' is flying around ...
We all know that...
set f to choose file
-- alias "My iMac:Desktop Folder:1"
f as string
-- "My iMac:Desktop Folder:1"
f as reference
-- alias "My iMac:Desktop Folder:1" of <<script>>
tell application "Finder" to open file "1" of desktop of application
"Finder"
-- file "1" of application "Finder"
We're getting closer to the kind of reference I thought Mark meant (maybe
not), and so ...
<script language="AppleScript">
-- with plenty of overkill...it was quick
set c to "tell application \"Finder\" to open "
set s to "file "
set e to " of desktop of application \"Finder\""
set d to (choose file of type "TEXT") as string
set AppleScript's text item delimiters to {":"}
set stepList to text items of d
--> {"My iMac", "Desktop Folder", "Volosinov, V.N. - Semiotics"}
set AppleScript's text item delimiters to {""}
set fi to "\"" & (last item of stepList) & "\""
-- set ci to "\"" & (first item of stepList) & "\""
set stepList to items 2 thru ((count stepList) - 1) of stepList
if ((count stepList) = 1) and ((item 1 of stepList) is "Desktop Folder")
then
if ci = "" then
set r to (c & s & fi & e)
else
set r to (c & s & fi & e & " of " & ci)
end if
else
-- Extra Credit
-- repeat for each item in the list, and build up a folder nest strin g
like:
--
-- " of folder \"" & (item x of stepList) & "\""
end if
r
--> "tell application \"Finder\" to open file \"1\" of desktop of
application \"Finder\""
run script r
--> file "1"
</script>
--
Gary
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.