Re: folder action help
Re: folder action help
- Subject: Re: folder action help
- From: Daniel Shockley <email@hidden>
- Date: Wed, 28 Feb 2001 22:06:46 -0800 (PST)
>
Message: 14
>
Date: Tue, 27 Feb 2001 16:08:35 -0500
>
Subject: folder action help
>
From: Adam Tabak <email@hidden>
>
To: <email@hidden>
>
>
Would someone please figure out why the following Folder Action isn't
>
working:
>
>
on opening folder (daFolder)
>
try
>
set oldId to AppleScript's text item delimiters
>
set AppleScript's text item delimiters to ":"
>
set fName to the last text item of (daFolder as string)
>
set fileName to "password-" & fName
>
set theAlias to "iBook HD:System Folder:Preferences:password:" &
>
fileName
From this snippet, I think I can see the problem. If the AppleScript TIDs are":" and you ask for
the last text item of a folder, you get ""
That's because the delimiter is the last item, so there is a NULL string _after_ the last
delimiter. The problem probably starts there and gets passed on. So, in the line that "set
fileName to " etc, you're setting fileName to "password-" & ""
You can fix this by using this line instead:
set fName to the second item of the reverse of (text items of (daFolder as string))
-- There may be a more concise way to say it, but don't try to get the second text item of the
reverse of daFolder. The (reverse of daFolder as string) itself would have all the characters
backwards.
Here, if daFolder is "iBook HD:Documents:AppleScripts:"
the text items of (daFolder as string) are {"iBook HD", "Documents", "AppleScripts", ""}
the reverse of that is, of course: {"", "AppleScripts", "Documents", "iBook HD"}
so the second word of that is the folder's name
Of course, you have to be sure you've got a folder for this to work, but it seems like you did,
based on what you named the handler and the variable.
PS. I CC'd Adam, since this was posted a ways back - it takes me a while to keep up with this
list, but it's worth it. I love that List-to-Record conversion by Olof.
Hope that helps,
=====
Daniel A. Shockley
email@hidden
http://www.krioni.com
And now for a message from my sponsor... *grin*
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/