Re: move folder & copy image ? (newbie)
Re: move folder & copy image ? (newbie)
- Subject: Re: move folder & copy image ? (newbie)
- From: Nigel Garvey <email@hidden>
- Date: Tue, 7 Aug 2001 22:40:14 +0100
Andy Wylie wrote on Tue, 07 Aug 2001 13:20:55 +1200:
>
set x to (path to frontmost application) as string
>
>
--------Finder
>
tell application "Finder" to set foldPath to (container of alias x) as
>
string
>
>
--------Standard Additions 'offset'
>
set foldPath to x's text 1 thru -(offset of ":" in "" & x's items's reverse)
>
>
--------TIDs
>
set AppleScript's text item delimiters to ":"
>
set foldPath to "" & text items 1 thru -2 of x & ":"
Or, in the spirit of not having to coerce unnecessary lists:
set foldPath to text 1 thru text item -2 of x & ":"
Or:
set foldPath to text from text item 1 to text item -2 of x & ":"
>
set AppleScript's text item delimiters to ""
>
>
--------Looney (an NG/A.Knapp hybrid %)
>
tell no to (alias (text of "" as string)) as string
Looney????!!!! Well, OK. But actually, it's an obfuscation of the
simplest method of all for finding the container folder of the
application running the script.
"" as alias
or
":" as alias
Both of these return an alias to the application's folder. It's a
relative-addressing system, so you can also easily get stuff like:
-- another file in the same folder
":my file" as alias
-- a file in a subfolder of the folder
":my subfolder:my file" as alias
-- the folder containing the folder
"::" as alias
-- a file in a sibling folder of the folder
"::my sibling folder:its file" as alias
-- etc.
(Of course, real names should be substituted for "my file", "my
subfolder", etc.)
NG