Re: getting the date, next question
Re: getting the date, next question
- Subject: Re: getting the date, next question
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 31 Dec 2003 09:59:05 -0800
On 12/31/03 9:31 AM, "Michelle Steiner" <email@hidden> wrote:
>
On Dec 31, 2003, at 10:04 AM, Simon Kidd wrote:
>
>
> set foldername to days_date
>
> tell application "Finder"
>
> activate
>
> make new folder at folder "Documents" of folder "Toby" of folder
>
> "Users" of disk "PowerMac_HD" with properties {name:foldername}
>
> reveal result
>
> end tell
>
> ------------------
>
> I now want the script to move something into the new folder, but how
>
> do I refer to the new folder if I dont know its name?
>
>
set dayfolder to (make new folder at folder "Documents" of folder
>
"Toby" of folder "Users" of disk "PowerMac_HD" with properties
>
{name:foldername})
>
>
dayfolder will be an alias to the folder.
It will? Says who? 'dayfolder' is a 'variable' name representing the folder
itself. In some languages that might be called a 'pointer', but I believe
that's not technically accurate in AppleScript. Still that's how it works.
The command (event) 'set' - like most AppleScript commands - has a result.
Setting a variable, such as 'dayfolder' - or any name containing only
alphanumeric characters and underscores (and which must begin with an
alphabetic character or underscore, not a number) which isn't otherwise a
"reserved keyword" of the AppleScript language, of the application of the
application tell block in which it occurs, or of an an installed scripting
addition, can be used to represent the result of 'set', just the same as if
you did:
(make new folder at folder "Documents" of folder
"Toby" of folder "Users" of disk "PowerMac_HD" with properties
{name:foldername})
set dayfolder to result
tell application "Finder"
set dayfolder to (make new folder at folder "Documents" of folder
"Toby" of folder "Users" of disk "PowerMac_HD" with properties
{name:foldername})
end tell
That's a variable in action.
This is an alias:
alias "PowerMac_HD:Users"Toby:Documents:"
It points to your user Documents folder, even outside any application tell
block. It "belongs to" the file system. The Finder knows how to coerce
aliases to its own files and folders. So you could also write:
tell application "Finder"
set dayfolder to (make new folder at alias
"PowerMac_HD:Users"Toby:Documents:" with properties
{name:foldername})
end tell
If it's going to be more convenient to use it as an alias later (for example
if you want to keep track of it even after renaming it or moving it) then do
it this way:
tell application "Finder"
set dayfolder to (make new folder at alias
"PowerMac_HD:Users"Toby:Documents:" with properties
{name:foldername}) as alias
end tell
--
Paul Berkowitz
_______________________________________________
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.