I have an AppleScript that moves and renames things, depending on the date at which it’s done. The workflow I’m using expects to see something named with the day of the week, as in “Sunday.”
I currently call a shell script to do this:
set DayOfWeek to (do shell script "date '+%A'" as string)
…and that does work, but I’d just sort of, you know, feel better if it was all in AppleScript vs calling out to shell scripts.
I see two ways to do this, but both appear to be (in their own way) unreliable. First, I could just grab the frist word of the date string, but that could change with localization or other issues - it relies on the date string being in a particular order, and that’s brittle.
The second is to just get the weekday:
set DayOfWeek to the weekday of current date
The only problem I have with that is that I want to ensure I get “Friday” and not “friday” or “Fri.” or “fri.” Is there a way to specify? How does AppleScript decide which to return (i.e., can I rely on it?)
Yes, I read that many times, but I have never heard of the weekday returned in abreviated form. I think it means that you can use the abreviated form as string to specify a date. e.g.
set w to “Fri, Jun 1, 2007”
date w
but not the other way around.
Edited: about case. Note that by default, AppleScript is case insensitive unless you use the ‘considering case’ statement.