AppleScript to automatically copy a folder into another folder?

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

  1. sultanoflondon macrumors 6502

    Dec 3, 2013
    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 68030


    Jan 26, 2014
    Horsens, Denmark
    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


    Jan 6, 2015
    Prague, Czech Republic
    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


    Feb 12, 2008
    East Riding of Yorkshire, UK

Share This Page