Mac Automation: Is this even possible?

Discussion in 'Mac Basics and Help' started by kevswords, Apr 8, 2016.

  1. kevswords macrumors newbie

    Joined:
    Apr 8, 2016
    #1
    Here's an outline of the action plan. Running a 2011 MBA w/ El Capitan. Is what I'm after even possible? I've tried using Automator's pre-made actions as well as its "record what I do" feature and didn't have much luck. These are all actions I do daily, and it's all routine stuff that seems like it should be able to be automated.

    1- startup at some set time (say, 4am)

    2- open Apple Mail, move messages from a specified IMAP folder into an 'On My Mac' folder

    3- empty Mail trash can

    4- close Apple Mail

    5- run a program called Email Archiver that turns messages in specified 'On My Mac' folder into .PDFs on an external drive (connected via USB)

    6- open Apple App Store, download/install updates

    7- close App Store

    8- open iTunes, download available media, App updates (and potentially back up iOS device(s) via WiFi if it's not asking too much; I don't use iCloud for iOS backups)

    9- close iTunes

    10- run CCleaner

    11- close CCleaner

    12- run SuperDuper to backup laptop drive to external HD

    13- shut down (SuperDuper offers a 'Shut Down when complete' option so this last step is easy).
     
  2. 9fiftyfive macrumors member

    9fiftyfive

    Joined:
    Oct 26, 2015
    #2
    1- Waking from sleep, maybe. Waking from powered off, no.

    2- Open mail, yes. Move message, maybe.

    3- probably

    4- yes

    5- maybe

    6- open the store, yes. Update, probably not

    7- yes

    8- open, yes. Download media, yes. Back up iOS, probably not

    9- yes

    10- possibly

    11- yes

    12- maybe

    13- yes

    A lot would be done presumably using AppleScript and Automator.
     
  3. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #3
    Every recent Mac should have scheduled power-on.
    See here:
    https://support.apple.com/kb/PH18583?locale=en_US

    To find more info, google search terms:
    mac scheduled power on


    The 'pmset' command in Terminal can be used to set or read the power-on scheduled times.
    https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/pmset.1.html

    Here are examples, first without a scheduled on-time, and then after enabling one in System Preferences > Energy Saver > Schedule...
    Code:
    host:dir uname$ pmset -g sched
    No scheduled events.
    
    host:dir uname$ pmset -g sched
    Repeating power events:
      wakepoweron at 4:00AM every day
    Scheduled power events:
    [0]  wakeorpoweron at 04/09/16 04:00:00 by Repeating
    
     
  4. mildocjr macrumors 65816

    #4
    ^ pro user right here

    And to answer your question about the rest of the stuff, yes you can, it just requires working with Workflows in Automator and/or writing some AppleScript using Script Editor, then scheduling the task as chown stated.

    But honestly, if you dropped money on a Mac just to do this then it seems like a waste since all of this could have been done with Linux on a cheap machine.
    --- Post Merged, Apr 8, 2016 ---
    As for more in-depth on this

    1- startup at some set time (say, 4am)
    https://support.apple.com/kb/PH18583?locale=en_US

    2- open Apple Mail, move messages from a specified IMAP folder into an 'On My Mac' folder
    Automator WorkFlow or AppleScript

    3- empty Mail trash can.
    Bash rm -f -r ~/.Trashes

    4- close Apple Mail
    AppleScript or Bash

    5- run a program called Email Archiver that turns messages in specified 'On My Mac' folder into .PDFs on an external drive (connected via USB)
    AppleScript (unless it has Automator Workflows)

    6- open Apple App Store, download/install updates
    I believe Automator or you can just install the homebrew mas for easy bash scripting

    7- close App Store
    AppleScript or Bash

    8- open iTunes, download available media, App updates (and potentially back up iOS device(s) via WiFi if it's not asking too much; I don't use iCloud for iOS backups)
    AppleScript for downloading App Updates but you will not get a completion notice so either monitor iTunes Media Downloads folder for all downloads to finish (delete themselves) or set a specific time to keep open (may not grab all updates). iOS backups to iCloud over wifi happen automatically at 12 AM when your phone is plugged in and on the same Wi-Fi network I'm guessing this is the same for iTunes Backups (I don't use them). The backup must be initiated by the iOS device so you'll need to run your script at 11:45 PM and keep the computer on long enough for the backups to complete to make sure this happens.

    9- close iTunes
    AppleScript

    10- run CCleaner
    AppleScript (Workflow if available)

    11- close CCleaner
    AppleScript

    12- run SuperDuper to backup laptop drive to external HD
    AppleScript (Workflow if available)

    13- shut down (SuperDuper offers a 'Shut Down when complete' option so this last step is easy).

    With all that being said, if you really want to continue doing this, then you need to understand a principle that probably should be a law.
    The harder the work for the Admin the easier the work for the User, the easier work for the Admin, the harder the work for the user.

    Translated:
    You will be doing a lot of scripting to make all of this happen, probably leaving your comfort zone a few times and you may have to learn a few things along the way. Since the script touches multiple applications and monitors for progress and checks file directories, you're probably going to have a few "couple hour debug sessions" to get past before this script is fully functional.
     
  5. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #5
    Or tell the Finder to empty the Trash. The complete AppleScript for this is:
    Code:
    tell app "Finder" to empty trash

    Several of these are listed as AppleScript or bash, when Automator has an action that will quit any application. It's called "Quit Application", and it's easy to choose the application to quit.


    Finally, further questions about scripting or Automator should probably be posted to the Mac Programming forum:
    http://forums.macrumors.com/forums/mac-programming.73/

    I may ask the moderators to move this thread there; I'm currently undecided.
     
  6. mildocjr macrumors 65816

    #6
    Thanks for cleaning that up for me, I don't use it much and wasn't around my Mac when I wrote my post.
     
  7. dyt1983 macrumors 65816

    Joined:
    May 6, 2014
    Location:
    USA USA USA
    #7
    I think he wants to empty the trash can in Apple Mail, probably the Trash of the mail server. One would probably need to tell the Mail app to empty the trash (well I would write a script to talk to my IMAP server; POP or Exchange users are going to do something different).
     
  8. kevswords thread starter macrumors newbie

    Joined:
    Apr 8, 2016
    #8
    Thanks for the responses guys. Sorry I didn't weigh in earlier but I'm just now seeing all this. Good info, and a big help. I'm new to scripting but am encouraged to give it a try.
     

Share This Page