AppleScript to automatically copy a folder into another folder?

Discussion in 'Mac Programming' started by sultanoflondon, Jan 28, 2017.

  1. sultanoflondon macrumors regular

    Joined:
    Dec 3, 2013
    #1
    Hi all,

    Is it possible to have an AppleScript automation code running in the background at all times that copies a folder into another folder? Would this significantly decrease battery life or CPU performance on a MacBook? It would be better if it is possible to set the AppleScript to start at a certain time (say Monday at 12:00:00), programme it to activate a point a few seconds after this, and then close down after the operation is complete (say at Monday 12:10:00).

    How would I do this?

    Thank you!
     
  2. casperes1996 macrumors 65816

    casperes1996

    Joined:
    Jan 26, 2014
    Location:
    Horsens, Denmark
    #2
    You definitely don't need to have it running at all times. There's a Unix command named "watch" that will activate programs periodically, so set it to activate your program every 168 hours, and your program will run every week. I don't think it comes with standard macOS, but you can install it with Homebrew. Regarding writing the actual script, I've never actually used Apple Script, but if you want to make it as a bash program, all it is, is "cp -r 'path to first directory' 'path to second directory'"

    Same might work in Apple Script, but definitely works for bash.
     
  3. Toutou macrumors 6502a

    Toutou

    Joined:
    Jan 6, 2015
    Location:
    Prague, Czech Republic
    #3
    Provide more info. There is even a way to launch your script only when anything changes in a certain folder (it's called a "folder action").
     
  4. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #4

Share This Page