Re: Desktop question
Re: Desktop question
- Subject: Re: Desktop question
- From: "Marc K. Myers" <email@hidden>
- Date: Tue, 23 Jan 2001 13:54:30 -0500
- Organization: [very little]
Bill Cheeseman wrote:
>
Date: Mon, 22 Jan 2001 21:18:24 -0500
>
Subject: Re: Desktop question
>
From: Bill Cheeseman <email@hidden>
>
To: AppleScript-Users Mail <email@hidden>
>
>
on 1/22/01 5:15 PM, Marc K. Myers at email@hidden wrote:
>
>
> If I say
>
>
>
> tell application "Finder"
>
> set theAlias to (duplicate file "someFile") as alias
>
> end tell
>
>
>
> and someFile is on the startup disk's desktop, it works just as I'd
>
> expect it to. The variable "theAlias" contains an alias reference to
>
> the new copy of the file. But if someFile is on some other volume's
>
> desktop, I get
>
>
>
> -->Finder got an error: Can't get folder "Desktop Folder" of disk
>
> "Communications".
>
>
When you run the script on a file on the other disk, you have to tell the
>
Finder that it's on the other disk. Something like this:
>
>
set theAlias to (duplicate file "someFile" of folder "Desktop Folder" of
>
disk "Other Disk") as alias
>
>
Or maybe just this:
>
>
set theAlias to (duplicate file "someFile" of disk "Other Disk") as alias
The script I'm trying to write is a droplet, so the file reference
coming in is an alias, which ought to include the volume information.
on open (itemList)
set fileList to {}
repeat with anItem in itemList
if character -1 of (anItem as text) is not ":" then
procFile(contents of anItem) -- an alias reference
end if
end repeat
end open
on procFile(fileAlias)
set fileText to (fileAlias as text)
set {od, AppleScript's text item delimiters} to [optn-L]
{AppleScript's text item delimiters, {":"}}
set fileName to text item -1 of fileText
set AppleScript's text item delimiters to od
if length of fileName < 27 then
set fileName to fileName & " [NR]"
else
set fileName to text 1 thru 26 of fileName & " [NR]"
end if
tell application "Finder"
set newFile to (duplicate fileAlias)
set name of newFile to fileName
end tell
Kill Resource Fork newFile
end procFile
What I want to do is make a copy of each file in the same location as
the original, rename the copy, and process it through the "Kill Resource
Fork" osax.
The duplicate runs OK and returns a Finder reference to the new file:
tell application "Finder"
duplicate alias "Communications:Desktop Folder:UnderConstr Catlg"
--> file "UnderConstr Catlg copy" of folder "Desktop Folder" of disk "Communications"
Then I tell "Finder" to rename the copy:
set name of file "UnderConstr Catlg copy" of folder "Desktop Folder" of
disk "Communications" to "UnderConstr Catlg [NR]"
But this returns an error:
--> Finder got an error: Can't set folder "Desktop Folder" of disk
"Communications" to "UnderConstr Catlg [NR]".
The duplicate is named with a full Finder reference, including the
volume, but for some reason the script fails where I tell the Finder to
"set name". Unless I'm missing something, it's doing what Bill
suggested, but it's still not working.
Marc [1/23/01 1:53:49 PM]