Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jbsmithmac

macrumors regular
Original poster
Sep 11, 2011
244
0
Hi,
I'm new to applescript and I'd like to do something specific on the first (or last) day of the month.

So how do I write something like:
If current date is "first day of the month" Then do XYZ
 
incase anyone else happens to be searching for this one day…I figured it out.

Basically I needed my script to do something different once a month - it could have been any day of the month, it didn't really matter.

Being that for most months there are a number of days that exist for each month (the 1st of each month, 2nd 3rd, etc.) but not every month has a 31st, so if you can get away with out needing the last day then this would work (or you could do something like the 1st - 1 day)

Anyway here's what I did…pretty simple. This only runs on the 1st of each month.

Code:
set myday to day of (current date)
     if myday = 1 then
     do whatever you need here
end if
 
You could use the same technique to run on the last day of the month as well, if you really had to do that for some reason. You can add seconds to "current date", so just change the first line to "set myday to day of ((current date) + 86400)"
 
Hi,
I'm new to applescript and I'd like to do something specific on the first (or last) day of the month.

So how do I write something like:
If current date is "first day of the month" Then do XYZ


Automator is what you want. Create a new calendar event and go from there.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.