This may be beyond KM, but does anyone know (and want to share with me) a macro for adding the week of the year number and the dates to a folder name? For example: My Folder Week 23 - Jun 01-07
I could also supply the week number via a user prompt. The big thing is that I want an automated way of taking that week number and turning it into a date range.
PS: Here's the week numbers and dates I'm talking about, but I need KM to work across years as dates change per week number. https://www.epochconverter.com/weeks/2020
I always thought creating Dictionaries would be fitting, for this type of dataset, but I don't know how to make effective dictionaries and parse that data, I'll await the guru responses.
I think this can be done in KM, maybe with some scripting.
But I'm unclear what you want to use for input data.
Do you simply want to get the Date Range as text given an input of the Week Number?
You could then combine that text in any way you want to build a folder or file name.
Technically the time should be 00:00, but since we are only dealing with days, I ignored the time. Correcting for Time Zone and DST is a royal PITA, but we don't need it here.
MACRO: Calculate the Start/End Date for a Given U.S. Week Number [Example]
-~~~ VER: 1.0 2020-06-01 ~~~ Requires: KM 8.2.4+ macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))
I would have NEVER came up with this. @JMichaelTX is on top of the game.
To match the EpochConverter date list that @iampariah referenced , I had to modify your macro from -1 to -2. I don't know which one is technically correct, but it matches.
Thank you very much, @JMichaelTX. That was exactly what I needed. I turned it into a sub macro that I call at folder creation time, prompting the user for the week number. The sub is called again within a For Each Finder Selection to rename all the folders at the end of the year to prepare them for the next year.
Thank you so much for the incredible help. Can I buy you a beer?
PS: As @kcwhat noted, changing your -1 to -2 aligned the dates with the Epoch Converter; the -1 had them out of date.
The ICUDateTime token supports ICU date week references, including the year of the week of the year
Symbol
Meaning
Example(s )
y
year
yy
96
y or yyyy
1996
Y
year of "Week of Year"
Y
1997
w
week of year
w
27
ww
27
So assuming you want Monday - Sunday weeks:
So My Folder Week 23 - Jun 01-07 would be:
My Folder Week %ICUDateTime%ww - MMM% %ICUDateTimeMinus%0%Mondays%dd%-%ICUDateTimePlus%0%Sundays%dd%
Note that across the end of the month you would get this:
My Folder Week 26 - Jun 29-05
So you may want to think about handling this.
Also note that the ICUDateTimePlus token only accepts the current date, so you would have to use a different solution for if you wanted to work with an arbitrary time, otherwise this will work for any case where you know the relative time you want (eg if you run it on Wednesday, and want it for next week, you could make that work).
My solution is for the US week numbering system.
As your Epoch ref points out:
All weeks are starting on Monday and ending on Sunday .
Please note that there are multiple systems for week numbering, this is the ISO week date standard (ISO-8601), other systems use weeks starting on Sunday (US)