*this list rocks
*this list rocks
- Subject: *this list rocks
- From: John McKenzie <email@hidden>
- Date: Fri, 30 Jun 2006 15:59:32 -0400
HI, just a lurker who wanted to write in to say that Spotlight plus a
year or two of mail messages from this list is an excellent resource.
I almost always find what I need (as below) -- remarkable.
Thanks to all,
John McKenzie
Libby Perszyk Kathman
Cincinnati OH
On May 8, 2006, at 3:13 PM, Jonathan Piccolo wrote:
That's awesome! Worked like a charm Christopher! I popped this into
my script and all is right with the world.
Incidentally, System Events can also do this, but (a) has no
scruples about invisible items and (b) knows where the preferences
folder is itself, so you can simply say this:
tell application "System Events"
if not exists folder ".aPCheck" of preferences folder then ...
end tell
Thank you, also, Michelle, et. al, for hanging in there with me :)
Regards,
Jonathan Piccolo
---------------------------------------------------
email@hidden
http://www.callthemacwizard.com
On May 8, 2006, at 1:44 PM, Christopher Nebel wrote:
On May 8, 2006, at 10:11 AM, Jonathan Piccolo wrote:
Full code for reference in case I'm doing something stupid (very
likely):
property antiPiracy : (path to preferences folder from user
domain as text) & ".aPCheck"
set folderName to ".aPCheck"
tell application "Finder"
if (not (exists alias folderName)) then
display dialog "This script was not installed correctly. Please
reinstall." buttons {"Quit"} default button 1
error number -128 --Quit was pressed
else
return 0
end if
end tell
You're getting closer, but there are still three errors, one
obvious, two not. First, the obvious one:
if (not (exists alias folderName)) then
"folderName" is merely the string ".aPCheck", so this isn't
testing for the existence of a folder named ".aPCheck" in the
place that you want, but rather in the Desktop folder. (The
desktop is the implicit container of otherwise unspecified Finder
items.) What you want, given the way the properties are now set
up, is this:
if (not (exists alias antiPiracy)) then ...
Except that it isn't. This brings us to the first of the
unobvious errors. Finder will not admit to the existence of an
invisible folder if you refer to it as a "folder", but it will if
you call it an "item". This gives us:
if (not (exists item antiPiracy)) then ...
This works, but only on your machine! This is the second
unobvious problem: property values are evaluated at compile time
and stored in the script. This means that "antiPiracy" gets set
to a path to *your* preferences folder, which probably won't work
on someone else's machine. To get around this, simply don't use a
property for the path part:
if (not (exists item folderName of folder (path to preferences
folder))) then ...
Incidentally, System Events can also do this, but (a) has no
scruples about invisible items and (b) knows where the preferences
folder is itself, so you can simply say this:
tell application "System Events"
if not exists folder ".aPCheck" of preferences folder then ...
end tell
--Chris Nebel
AppleScript and Automator Engineering
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (Applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden