I've managed to cobble together a macro to create a new folder in the front most finder window named todays date, but what I'm struggling with is creating a folder which takes the current time (say 0824) and rounds up to the nearest half an hour for the name. So the macro would create a folder called 0830 in this instance. If the time was 0836 it would create a folder called 0900. Is this possible at all? I've had a look at some of the 'ROUND' functions but not sure if that's what I need.
Hmmm… my first thought would be to use the ICUDateTime token, specifically the minute portion of it, and using RegEx to create a temporary variable to be used in the creation of the folder. There is probably an easier way to do this than mine but give me a minute and I’ll post an example.
EDIT: @petejonesmusic Ok, here's a rough draft that shows how you can use RegEx to check the ICUDateTime minute token and set local variables to use in the creation of a folder. Note that this is based off the assumption that you always want the time rounded up to the next half hour (since that's how I understood your post), even if the time is say 18:00 on the hour; that would be rounded up to 18:30.
Anyhoo, this might get you going with what you need. If you need further help understanding it, modifying it (like right now it's setup in military time since I find that the best format for hierarchical folder organization), or implementing it just let me know and I'll see if I can help further!
01)Scratchpad.kmmacros (3.9 KB)
Macro screenshot (click to expand/collapse)
That is fantastic - I've managed to get it into my macro - just one problem. Although the text displayed is "10:30" the folder that it creates for some reason comes up as 10/30. Any idea why that would be the place?
Create a Folder Rounded to each 30 mins.kmmacros (13.8 KB)
Great! Glad it is helping. For your question, trying removing the colon from these actions (it was in my macro just for demonstrative purposes, but for file paths it needs to be removed):
Fantastic that's done it! So if I follow correctly, when the time goes to say 1031 and I trigger the macro, it will create a folder '1100'?
Thanks so much!
That’s great! And yes that’s correct. If you run into any issues with it just let me know and I’ll help troubleshoot it.
A hack that I frequently use — because I often want to use a colon in a filename! — is instead to use the Unicode small-form variant
SMALL COLON (code point #65109 [U+FE55]), which Finder, Keyboard Maestro, Terminal, and Hazel (at least!) have no problems with:
(And neither does Discourse or your web browser, if you can see the above “small colon”!)
It’s important, of course, to remember that this is not a colon character — so you can’t use
SMALL COLON in a file’s name and then expect to match
COLON in a KM macro or shell script. But as long as you consistantly use the
SMALL COLON character in any relevant scripts, you should be fine.
Definitely a hack, but one I’ve been using with no problems for at least a decade….