Re: What is wrong with my script
Re: What is wrong with my script
- Subject: Re: What is wrong with my script
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 11 Sep 2009 12:13:48 -0700
- Thread-topic: What is wrong with my script
That's not a file (in Finder terms). It's a folder - the Applications
folder. POSIX file objects do not have modification dates or any other
Finder properties. You first have to coerce it to a folder, or at least a
Finder item (perhaps you don't know in advance if it's a folder or a file,
so just use item).
For some reason the Finder won't do that coercion directly from a POSIX
file, but it will do so from an alias object. In fact, alias is all it
needs. It will even do the coercion with its own Finder tell block (which it
won't do directly 'as folder' or 'as item'). You don't need a second
explicit coercion from alias to folder or item.
set AS_path to POSIX file "/Applications/"
tell application "Finder"
set dat to modification date of (AS_path as alias)
end tell
I'm assuming there's some reason why you want to preserve the AS_path as a
POSIX file. If not, it's a good rule to always to that coercion immediately
before you do anything else:
set AS_path to POSIX file "/Applications/" as alias
tell application "Finder"
set dat to modification date of AS_path
end tell
(After all, why call it an AS_path otherwise? You'll get more use out of it
in AS as an alias, or 'as alias as text' if you need just the text path.)
--
Paul Berkowitz
> From: xorx <email@hidden>
> Date: Fri, 11 Sep 2009 20:53:39 +0200
> To: AppleScript-Users <email@hidden>
> Subject: What is wrong with my script
>
> Running the following script in AppleScript editor creates error -1728:
>
> --start
> set AS_path to POSIX file "/Applications/"
> tell application "Finder"
> set dat to modification date of AS_path
> end tell
> --end
>
> It says that "modification date of file "/Applications/"" could not be
> read. This error happens with all possible properties of file objects.
> The file obviously exists and I have no clue why this does not work...
>
> Thanks for any help,
>
> Georg
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> 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:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden