I’ve been reading a lot on the net about AS and am trying to create a backup script. So far it mounts the external SMB volume, quits Entourage if it’s open and then at the critical point of copying, I get the following error in the Event Log:
tell application “Finder”
copy file “Wakko:Users:corey:Desktop” to disk “NUMBER2 (D)”
“Finder got an error: Can’t set disk "NUMBER2 (D)" to file "Wakko:Users:corey:Desktop".”
Here’s the script:
tell (application “Finder”)
try
mount volume “smb://192.168.10.50/NUMBER2 (D)/”
as user name “corey” with password “password”
on error
display dialog “There was an error mounting the Volume.” & return &
return & “The server may be unavailable at this time.” & return & return
& “Please inform the Network Administrator if the problem continues.” buttons
{“Okay”} default button 1
end try
end tell
tell application “Microsoft Entourage”
quit
end tell
tell application “Finder”
duplicate file “Wakko:Users:corey:Desktop” to disk “NUMBER2 (D)”
end tell
“NUMBER2 (D)” is the SMB volume. I’d eventually like to specify an exact location on that volume (like a folder called “Mac Backup” or some such name), but just getting it to copy would make me happy at first.
Any help much appreciated. I’m a NEWBIE, so please be elementary when you can.
Thanks!
Corey
Model: PB G4/867 MHz
Browser: Safari 412
Operating System: Mac OS X (10.4)
OK…Nevermind. I figured it out. (Reading the ‘manual’ always helps.) I found some more stuff, so here’s my final script that will mount an SMB volume, quit Entourage if it’s open, copy my Home folder to the SMB volume and unmount the SMB volume in one step.
tell (application “Finder”)
try
mount volume “smb://192.168.10.50/NUMBER2 (D)/” as user name “corey” with password “password”
on error
display dialog “There was an error mounting the Volume.” & return & return & “The server may be unavailable at this time.” & return & return & “Please inform the Network Administrator if the problem continues.” buttons {“Okay”} default button 1
end try
end tell
tell application “Microsoft Entourage”
quit
end tell
set shareName to “NUMBER2 (D)”
set localFolder to “Wakko:Users:corey:”
set remoteFolder to “NUMBER2 (D):Mac Backup:”
tell application “Finder”
duplicate every file of folder localFolder to folder remoteFolder with replacing
end tell
tell application “Finder”
activate
eject disk “NUMBER2 (D)”
end tell
YEA!
If you can suggest improvements on this, please do! I’m brand new at this and wonder if what I don’t know might hurt me.
THANKS!
Corey
It is working for the most part, however, it doesn’t copy directories within a folder. All it copies are files. I had one text file in the Home directory, and that is what was copied. The Folders within the folder were not copied. How do I specify to get all folders in a directory and copy them? I’m at a loss on this one!
tell (application "Finder")
try
mount volume "smb://192.168.10.50/NUMBER2 (D)/" as user name "corey" with password "password"
on error
display dialog "There was an error mounting the Volume." & return & return & "The server may be unavailable at this time." & return & return & "Please inform the Network Administrator if the problem continues." buttons {"Okay"} default button 1
end try
end tell
tell application "Microsoft Entourage"
quit
end tell
set shareName to "NUMBER2 (D)"
set localFolder to "Wakko:Users:corey:"
set remoteFolder to "NUMBER2 (D):Mac Backup:"
tell application "Finder"
duplicate every item of folder localFolder to folder remoteFolder with replacing -- replaced "every file" with "every item"
end tell
tell application "Finder"
activate
eject disk "NUMBER2 (D)"
end tell
You told the finder to duplicate every file, so it did :).
That got me going. However, the “replace” function doesn’t seem to work. I have to
tell application “Finder”
delete items of folder remoteFolder
end tell
Then I have the script move everything over. Is there something I’m missing on the “replace” to get it going?
Just to wrap this up, I got this going by using “replacing yes” instead of just “with replacing yes” in the duplicate items line. I did start to go into erasing the destination first, then copying over, but it seemed the replacing funciton should work. I guess “with” was unnecessary.