Re: Variable renaming and managing a folder
Re: Variable renaming and managing a folder
- Subject: Re: Variable renaming and managing a folder
- From: Graff <email@hidden>
- Date: Sat, 22 May 2004 20:18:21 -0400
On May 22, 2004, at 4:52 PM, Bernard Azancot wrote:
Le 22 mai 04, ` 21:24, email@hidden a
icrit :
set thePath to (((path to startup disk) as text) &
"Volumes:volname:rest:of:path:")
I do not understand the meaning of (((path to startup disk) as text)
&"Volumes:volname:rest:of:path:")
compared to the simple:
set thePath to ("VolumeName:folder:folder:")
Well, the first statement is a bit redundant but I do it anyways.
Under Mac OS X your startup disk is the root disk, if you go into the
Terminal your root is the path "/". All of the other mounted disks
(volumes actually) have what are called "mount points" and they are
stored in the path "/Volumes/". So to get to the volume
"AnotherVolume" you would go to "/Volumes/AnotherVolume/"
The "path to startup disk" part will always give you the path "Root
Volume:" if your startup disk is "Root Volume"
Under classic Mac OS and the Finder your root disk is at the path "Root
Volume:" The volume "AnotherVolume" is both at the path "Root
Volume:Volumes:AnotherVolume:" and at the path "AnotherVolume:" I'm
simply choosing the more explicit path because it more accurately
represents what is happening "under the hood". I'm pretty sure that
both ways will work similarly, but I know for certain that the explicit
path works well.
I have tried:
Copy folder"X" to thePath. It is refused. Why ?
There is no command "copy" in the Finder dictionary, the command you
are looking for is "duplicate". Here's the entry in the Finder
dictionary:
----
duplicate: Duplicate one or more object(s)
duplicate reference -- the object(s) to duplicate
[to location reference] -- the new location for the object(s)
[replacing boolean] -- Specifies whether or not to replace items in
the destination that have the same name as items being duplicated
[routing suppressed boolean] -- Specifies whether or not to
autoroute items (default is false). Only applies when copying to the
system folder.
Result: reference -- to the duplicated object(s)
----
So you would need to do:
----
tell application "Finder"
set folderToCopy to folder "path:to:folder:"
set thePath to (((path to startup disk) as text) &
"Volumes:volname:rest:of:path:")
duplicate folderToCopy to folder thePath with replacing
end tell
----
The "with replacing" part will cause the duplicate command to overwrite
a file or folder at the destination if it has the same name as the file
or folder being duplicated.
tell application "Finder"
What is the use of "activate" ? I have tested scripts with or without
it without noticing any difference.
When is it usefull to "activate" an application?
There are 3 commands that get a program going: "run", "activate", and
"launch". A "tell" statement will also usually start up an
application. The differences between the 3 commands are a bit murky.
Generally a "run" command causes the program to start up and open a new
document. An "activate" command causes the program to start up and
come to the front without opening a new document. A "launch" command
usually causes the program to start up behind other applications.
There is some inconsistency between how different applications handle
these but generally the only time you use them is when you want to
bring an application to the front (use "activate") or launch an
application without bringing it to the front (use "launch"). You'll
notice that I didn't use any of these commands, simply because I didn't
need to be concerned about bringing the Finder to the front or having
to launch it.
- Ken
_______________________________________________
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.