





Original Message: I'm downloading stock assets from Envato then using Hazel to match .zip files from that URL, then using Hazel actions to unarchive and rename them, replacing characters like "-" and "_" with spaces. Easy enough so far using the match patterns with the "Rename" action. However, the filenames also include dates at the end of the filename (I'm guessing upload dates), and they're typically always a different and generally unpredictable date.
Examples of unedited filenames include:
- list-titles-for-apple-motion-and-fcpx-2023-12-29-01-30-03-utc.zip
- id-card-mockup-2024-05-02-20-23-18-utc
What is predictable (as far as I've encountered, at least), is that the string is always the same number of characters (23 or 24, depending on whether you include the preceding hyphen or space). However, I couldn't find a function in Hazel from trimming characters in either direction, nor could I find a way (short of scripting) to match via Regex (e.g. ^\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2}-\w{3}$). Even with ChatGPT and Google, I'm also not quite skilled enough to figure out how to put together a script or Apple Shortcut to pass this task to (from Hazel, anyway—I do have renaming apps configured, but that defeats the point of trying to automate via Hazel).
Am I missing something? Is there a way within Hazel that I could accomplish this without further scripting? Or what would the script be? I couldn't figure out how to put together an Applescript that interacted with Hazel the correct way (at least with the in-app method).