Applescript + iCal just reminded me of how much I like OSX.

Discussion in 'macOS' started by Lau, Feb 20, 2006.

  1. Lau Guest

    This just made me very pleased to be using OSX. :)

    I'm building a new website, right, and I want to have a new image on the front page each day. (An image o' the day, if you will :D) I know I could automate this, but I also want to choose (or even create) the image the day before, so I wouldn't have a load of them saved or uploaded in advance.

    Now a friend of mine is struggling with php and all sorts for his site, for daily news and suchlike. As mine was just a case of uploading a new (identically named) image daily and php looks fairly difficult, I had resigned myself to logging in to FTP and uploading an image each morning over breakfast. Not a huge problem.

    But then I thought of Applescript (which I'd never used before), poked around in the help, and used the "Record" function to tell the script to open Fetch, log in, upload the file off the desktop and then quit Fetch. Then I went into iCal, and set it to do it at 9 am every morning. Tested it, and it works. :) And if I'm not on the computer at 9, I can just click on the script once I am, which is still so much less hassle.

    Isn't that great? Two programs that you get free with a Mac and a n00b like me can understand that are going to make this so much easier.

    <Pleased> :eek:

    Here's the script in case anyone wants to do anything similar in the future.

    tell application "Fetch"
    	make new transfer window at beginning with properties {hostname:"", username:"username", password:"password"}
    	open remote item "www"
    	open remote folder "Images"
    	put into transfer window "" item alias "me:Users:me:Desktop:imageotheday.jpg" format Automatic without uniquename
    end tell
    <Goes off to write more Applescripts for everything> :D
  2. Applespider macrumors G4


    Jan 20, 2004
    looking through rose-tinted spectacles...
    Congratulations Lau - I'm very impressed! ;)

    Hmmm, I wonder if I've got any tasks that I could use Applescript for - I might just have a look around in the Help files and see if it gives me any ideas.
  3. Lau thread starter Guest

    Thanks! If only there was one like:

    tell appliance "Kettle"
    	make clean cup at beginning with properties {coffee:"one", milk:"zero", sugar:"zero"}
    	pour item "item"
    	use item "spoon"
    	put into hands "Lau" item alias 
    end tell
    Darn. <Gets up to put kettle on, grumbling>


    Seriously though, you could get it to do almost anything on the computer, and the good thing is the record feature, as it saves you having to work anything out. You could just work away as usual recording, I suppose! The only thing it didn't notice was me quitting Fetch, so I had to look that up and add it. (It was "Quit" funnily enough :p ). But I was impressed how accessible and easy it was, considering it is writing a mini program really.

Share This Page