Re: Renaming a file...
Re: Renaming a file...
- Subject: Re: Renaming a file...
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 17 May 2002 12:01:05 -0700
On 5/17/02 10:48 AM, "Monsoft" <email@hidden> wrote:
>
le 17/05/02 16:51, Doug McNutt ` email@hidden a icrit :
>
>
> At 11:02 +0200 5/17/02, Monsoft wrote:
>
>> set myDuplicateFile to duplicate file myFile to folder myFolder
>
>> -- work fine
>
>> set the name of the file myDuplicateFile to myNewName
>
>> -- I'm enable to rename the file!
>
>
>
> Allow me to guess. If I'm right perhaps I can say I'm finally getting this
>
> English dialect.
>
>
>
> myDuplicateFile is in the form of a file alias - one way of specifying a
>
> file.
>
> It gets created by your first command.
<snip>
>
You're right!
>
"the file" was superfluous and toxic!!
>
set the name of the file myDuplicateFile to myNewName -> error
>
set the name of myDuplicateFile to myNewName -> OK
>
>
however it's a file... I'm not at ease with english grammar. Thanks.
But this is nothing to do with English grammar - it's AppleScript grammar.
It would be exactly the same in French or any other language.
The issue, as Doug said, is that you set the variable 'myDuplicateFile' to
the result of the 'duplicate' command. That means that it is an object, NOT
a string. Actually, since you're still within a Finder block at that point,
the result really IS a file - a Finder file. You can easily coerce it to an
AppleScript alias but that's not the main point.
Sticking the term 'file' in front of a variable which already is a file, or
alias, or anything other than a string, is going to error. That would be
true in French dialect as well. There are ways of setting the variable to
a string instead (and here you really would have to coerce it first to
alias, then to string) and then you could put 'alias' or 'file' in front of
it (and then you might run into the recent ug Doug refers to if you used
'file' rather than 'alias').
But the main thing is that you should keep track of the fact that you set
your variable to a file, not to a string name or string path. So the
file-ness of it is already contained in your variable and must not be added
on a second time.
--
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.