Saturday, April 19, 2014

#1 2004-11-18 08:33:20 am

tozzini
Member
Registered: 2004-11-18
Posts: 17

How to make a script do mount a server folder and copy files

Hi folks,

I'm a newbie in applescript programming and i need one script that have to mount a server disk and copy some files to that folder. And this is to be in time scheduled.

Can anyone help me with that??

Thanx a lot

Andre Tozzini

Offline

 

#2 2004-11-18 09:44:58 am

somethingkindawierd
Member
From: San Luis Obispo, Ca
Registered: 2004-07-08
Posts: 63
Website

Re: How to make a script do mount a server folder and copy files

I have done something similar...the code is below.  Just change the specifics for your environment.

Applescript:

tell application "Finder"
--if you want to use an IP address instead of Rendezvous just replace it with the #
   set ThisVolume to "afp://log:password@Rendezvous-Name.local/Hard Drive Name"
   try
       if (list disks) does not contain "Hard Drive Name" then mount volume ThisVolume
   end try
   try --this will reveal the drive in a Finder window
       reveal folder "Hard Drive Name"
   end try
end tell

To copy files I have this handler to be called when needed.  You must specify a list of items to be moved and set the list to the variable theseItems.  Then you must set the variable thisFolder to the folder on the mounted drive that you intent to move to.

Applescript:

on moveItems(theseItems, thisFolder)
   --Input: theseItems is the list of items to be moved
-- thisFolder is the destination they are to be moved to
   --Output: true or false based on success of the move
   tell application "Finder"
       set folderContents to name of folders of thisFolder
       set itemName to name of theseItems
       --check to see if the file to be moved already exists in the target folder
       if folderContents does not contain itemName then
           try
               move theseItems to thisFolder --this is the line doing the work
               return true
           on error
               error --put your error command here
               return false
           end try
       else
           display dialog ("The folder '" & itemName & "' already exists in '" & thisFolder & "'.")
       end if
   end tell
end moveItems


Admin of AutomatorActions.com
Please share with the community and post any final Actions & Workflows to AutomatorActions.com

Filed under: Finder

Offline

 

#3 2004-11-18 05:03:37 pm

StudHamster
Member
Registered: 2004-11-18
Posts: 1

Re: How to make a script do mount a server folder and copy files

I'm also new to this AppleScript writing, but here's a Script I'm using.

tell application "StuffIt Deluxe"
    activate
    make new archive with properties {location:file "Location:NameOfCompressedFile.sit"}
end tell

tell application "StuffIt Deluxe"
    activate
    stuff {alias "FolderLocationToCompress"} into archive "NameOfCompressedFile.sit" compression level maximum
    quit application
end tell

I'm trying to compress folders on my Mac G5 (OSX), and place them on the server for archival. There's a problem I'm having with this though. When the folders are large and take a while to compress...they get an "AppleEvents timed out" error. Does anyone know how to disable the AppleEvents timeout pref? Or, another way of doing this.

thanks,


Filed under: Stuffit

Offline

 

#4 2004-11-18 08:13:54 pm

somethingkindawierd
Member
From: San Luis Obispo, Ca
Registered: 2004-07-08
Posts: 63
Website

Re: How to make a script do mount a server folder and copy files

I know you can tell a script to delay execution of the next command, making it wait for a specified time.  Just add the following anywhere you want the script to pause:

Applescript:

delay 600
--this will delay the script for 600 seconds

I am not sure how to do a conditional pause to make the script wait for an operation to complete before continuing.  I would be interested if anyone knew how to do this.

It might work to use a handler to verify if a file is busy, having it check to see if your Stuffit file is still being used or not.  The script could halt until this handler verifies the file is no longer being used, and then continue.  I have not had much luck with the "is busy" command, but once again, if anyone has had success with this I would be interested in seeing how is was done.

Hope these help in working towards a solution.

jON bEEBE


Admin of AutomatorActions.com
Please share with the community and post any final Actions & Workflows to AutomatorActions.com

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.029 seconds, 8 queries executed ]

RSS (new topics) RSS (active topics)