I have recently been looking at how I can use some Mac native tools to improve my workflow. Finally exploring tags and smart folders for example.
I even built my own Mac app which sits in my menubar syncing tags on project folders with the status of projects in a web app I built. Even better that is synced with iCloud so I can access all of those files and tags from my other devices.
I had not considered how else I could improve this situation with context menu options, but now I want to explore how I could use Automator to improve this setup even more.
Its kinda funny, I have shown 2 people this tool so far.
One is another engineer, who we kinda laughed over a tendency to spend an insane amount of time automating things that are quick. Like adding a tag to a folder is quick, I just didnt want to do it and things get out of sync.
But he also thought it was really cool and also did not really know about tags until we started talking about this. Kinda like me, he knew they were there but just never did anything with it.
I also showed it to my partner who kinda just keeps laughing every time he sees me glued to my laptop debugging this thing and tweaking it.
It has honestly been a really fun project though. Trying to keep things as native functionality as possible since the entire point of this is to make it so I can more easily work on a script or some other supporting document for a project on my iPad or iPhone and once I get on my Mac everything will just fall into place. I even made it so if I make a folder, it will send the name of that folder to my web app as a new project. (well the web app handles if its new or not, but still).
My only real annoyances so far:
1: Mac doesn't have the ability natively to automatically tag all files in a folder that the tags of the parent folder. I could script this, and I might. But I kinda wish I didn't have too.
2: Why is there no ability in Swift or a Mac app in general to read the contents of a Pages file. Honestly this kinda drives me insane. (I found a workaround by using a github project to turn it into HTML, but that really should not be necessary).
3: I really wish I could make a smart folder that would show me files based on the tags of the parent folder. This way I could have 2 folders in different locations (one that syncs with iCloud and one that syncs with my NAS with very different data, but used in combination) and I could create a smart folder with a single view of all of those files. But this unfortunately seems impossible. (Edit: I guess I could just automatically create symlinks, but a smart folder would be so much cleaner)
Sounds like we do similar organization, though I avoid Tags and use Keywords, which I prefer primarily because they can be embedded in many files types and can be more numerously assigned. Regardless, for much of your work assigning Tags and organizing files, have a look at Hazel for automating these tasks. And yes, it can read the contents of Pages files.
I did briefly look at Hazel, I think at this point it would likely be unnecessary.
I already have my app which has the custom code to work with the API of my web app and set tags accordingly, at that point it would honestly be trivial to have it go through all of the subdirectories of a folder. I would be quite surprised if I could have Hazel query an API, parse the json, loop through it, and then tag based on the various values.
Unless it solves my last issue? I did not think it did when I looked at it, since that is more a limitation of the smart folder filter than anything else.
That being said, I am confused by the difference between keywords and tags? Since on Mac a tag can be put on any file, folder, etc and doesn't care about the filetype. A single tag can be on any number of files/folders and a file/folder can have as many tags as I want (at least seemingly, I have not seen a limit yet).
When you say keywords, are you just referring to using certain... well keywords... in the filenames?
>Unless it solves my last issue? I did not think it did when I looked at it, since that is more a limitation of the smart folder filter than anything else.
I don't believe Hazel will solve that last issue, but I may be off about that and you're certainly more skilled than I am.
>When you say keywords, are you just referring to using certain... well keywords... in the filenames?
Keywords are not in the file name, they're embedded in a file's metadata. For example, do a Print to PDF of a web page, but in the last dialog where you can save, note there's a Keyword field. Add something there that's unique, then search on it with Spotlight. Have lots of Keywords in use? Then Spotlight can use a keyword:[search term] search, similar to how there are many other built-in search queries.
My primary setup is to have Hazel monitor specific files in specific folders looking for specific content within those files. Based on the results, Hazel runs my Automator Actions to embed the Keywords I want (especially helpful for organizing my business files, but I have plenty of other uses, like Hazel filing documents based on the Keywords I added when using Print to PDF).
Ultimately, it sounds like you have a solid system accomplishing most of what you want done. Certainly no need to redo a viable setup. I was just hoping Hazel could help with the Pages files, and maybe secondarily some other parts of your process.
> Keywords are not in the file name, they're embedded in a file's metadata. For example, do a Print to PDF of a web page, but in the last dialog where you can save, note there's a Keyword field. Add something there that's unique, then search on it with Spotlight. Have lots of Keywords in use? Then Spotlight can use a keyword:[search term] search, similar to how there are many other built-in search queries.
Ah I see now. If I understand properly, I can see the value in this if you are setting a ton of keywords across multiple systems, and you don't really want those to muck up your finder window or list of tags.
Out of curiosity I went to the save as pdf, and tag is also there. Honestly never noticed either being there.
I wonder why tags on Mac isn't just a layer built on top of keywords if that is already there. Tags are even available in smart folder filters.
Thanks for mentioning that, I think I might honestly use both. Since I use some tags for project status. So things like "research" "production" , etc etc. Things that are actually valuable as tags on my sidebar to quickly filter with. I even have colors associated with those to a quick glance at my folder.
But being able to add a keyword for each project would also be beneficial. It doesn't muck up my sidebar.
Keywords are more widely available than may be obvious. TextEdit accepts them, Preview in its Inspector panel, Photoshop has a field, Word and Excel did (do?) in File > Properties, and many others. I’m not near a Mac with Pages so I can speak to that app. And just like Tags, Keywords can be used with Smart Folders.
So I feel like this is a stupid question, but how do you add keywords to an existing file or folder? Like from Finder or the terminal.
That is the use case I am trying to do. I won’t ever be in a situation of saving a file with a keyword. The entire idea of my automation is that I don’t manage these tags/keywords myself.
I tried last night to do this, but I couldn’t figure out how. And googling didn’t help since every article just assumed I was talking about tags.
Edit: Also after some experimentation I think I am still not really understanding the value of keywords vs tags.
I guess the biggest is likely since it is a common and standard metadata that it works across platforms and not just within the Apple ecosystem?
You mention TextEdit, and Word. In both cases when I go to save a file since it uses the Mac native file save UI, the second box is tags.
You are right that in Word if I go to properties, I see Keywords and not tags. It is not clear to me if this is a limitation of Tags or just an oversight in the application. I was curious so I took an image, added a tag and opened it in preview. And the inspector panel does not show the tag.
So it seems like a bit of a tradeoff, with keywords you get metadata on the file itself that is very portable to any system. But being able to view the tags is limited to applications.
With tags, I assume this data is stored on the file itself (later today I will need to try to look at one of these files on my NAS and see if it can see the tags or not) but the applications don't show it (Apple's own application not showing it is kinda weird honestly) but you can manage and view tags from finder.
Sorry for the delay here, nerdjon. I hope this gets to you.
>...how do you add keywords to an existing file or folder? Like from Finder or the terminal.
As far as I'm aware, a folder can't have a Keyword assigned to it. Adding Keywords to files from the Terminal... I'm too Terminal-ignorant to help with that, but there should be a way. Many years ago — I've been on the Keyword bandwagon since before Tags were available — I found a way to bulk delete a Keyword from a bunch of files using a Terminal command. Since Keywords are often uncommon in most people's setups, it may help to search for other Spotlight-visible metadata that can be assigned to files from the Terminal, as it may then be a case of replacing that parameter with keyword in the command.
Most of my Keywords get assigned to files using Hazel. Hazel watches certain folders, looks for certain criteria, then runs Automator Workflows I've made which add the Keywords. If I need to more manually add Keywords, I have those same Automator Workflows in the form of Services, which are available from the the Finder Contextual Menu.
>That is the use case I am trying to do. I won’t ever be in a situation of saving a file with a keyword. The entire idea of my automation is that I don’t manage these tags/keywords myself.
Sorry to sound like a product shill, but that's why I rely on Hazel. It does the bulk of the work for me assigning Keywords. Just to describe what that means, let's say I get PDF invoices from five vendors. They go to the Downloads folder that I've set Hazel to monitor, Hazel looks for specific content in the PDFs (usually something like an account number or remittance address), then runs the specific Automator Workflows assigning the Keywords I want on each invoice, and finally Hazel moves the PDFs where I want them.
>I guess the biggest [keyword value] is likely since it is a common and standard metadata that it works across platforms and not just within the Apple ecosystem?
Agreed. And to me the greatest value in that isn't in sharing files with others — what are the odds a Windows user will care what Keyword I've assigned to a file? — it's that the copies of my files that are backed up to cloud services retain the Keywords. Second to that, the biggest value for me in Keywords over Tags is that I can easily add as many as I want.
>You mention TextEdit, and Word. In both cases when I go to save a file since it uses the Mac native file save UI, the second box is tags.
In TextEdit, File > Show Properties is where Keywords are added (to RTFs, etc., but not .txt files).
>You are right that in Word if I go to properties, I see Keywords and not tags. It is not clear to me if this is a limitation of Tags or just an oversight in the application.
I believe that's an app limitation, but I'm not running anything near the latest macOS or Word.
>I was curious so I took an image, added a tag and opened it in preview. And the inspector panel does not show the tag.
But the Magnifying Glass section of the Inspector Panel will accept Keywords. Tags, as far as I'm aware, are meant for Finder and may largely (completely?) be limited to places like that (aka, the iOS Files app also), but not for within apps.
>So it seems like a bit of a tradeoff, with keywords you get metadata on the file itself that is very portable to any system. But being able to view the tags is limited to applications.
Just like Tags, you can create Smart Folders in the Finder for Keywords. Or a Smart Folder for files with Tag:Red and Keyword:InProgress. That kind of flexibility is definitely a great feature of Smart Folders.
I hope this helps. I'm not out to convince you to switch from what sounds like a thorough, effective setup on your end. But I do hope this helps in any way.
I am almost positive I tried that, and I want to say no.
The problem is that apparently the Pages file is just a hidden bundle. But unlike apps, Final Cut Pro, and other Mac bundles unless you go into Pages and change an advanced setting per file it doesn't have the "Show Package Contents" that the others do.
msephton's sibling comment notes that Pages files are a ZIP bundle. (I just tested this, and that's the case - actually they're not even compressed, just stored.)
Inside this zip file there's a number of things:
- three preview JPGs at varying sizes (roughly 50px, 250px, 1000px)
- a Metadata folder with a couple of plists and a UUID file
- an Index folder which contains a bunch of .iwa files which appear to be some Apple iWork suite specific thing. I'm not sure if there's a real file format there or if they all have a different format keyed on the file name. If you run `strings` on one of them you could plausibly recover document text.
BetterTouchTool also includes functionality to customise Finder's context-menu. I was hoping Hammerspoon would have something similar in their arsenal of APIs, but it doesn't look like they do.
I've done this to strip Exif metadata from pictures using Automator. Uses homebrew and the exiftool package.
Workflow receives current "image files" in "any application"
Image = Action
Run shell script:
Shell: /bin/zsh
Pass input: As argument
for f in "$@"
do
/opt/homebrew/bin/exiftool -all= -tagsfromfile @ -ColorSpaceTags -Orientation $f
done
----
Will be under the Quick Actions menu.
I tried the same with Shortcuts, but I cannot get it to run from the context menu, only within Shortcuts during testing. Maybe something limiting shell command access from Shortcuts? Not sure.
Thanks! However, it lacks a couple of things the Automator script does. It wants to convert by default to JPEG instead of keeping the source format, it requires interactivity, and for some reason if I cancel the dialog, I can't get it to run again without relaunching Finder (on 14.6).
Semi-related, for devs who want to add Automator actions to their apps for users to make context menu items with, a while back I wrote a blog post and created a template that works with modern Xcode, since Xcode can no longer create them out of the box.
I enjoy some cool macos tricks, but the bash substitution was something I had never seen!
Very neat, I looked into it briefly and it looks like using {@%.*} is not posix compliant, but a bashism. However the substitution itself is posix compliant, so I may start using something like this in my scripts. Need to look at this more, but this is a heck of a lot less clunky than `echo | sed`... I need to go read `info coreutils` more closely.....
I've been using context menu quick action for a while [0] and they hugely improve my productivity. A few of my most used ones:
- Search Image (search selected image through google lens)
- Compress Images (compress selected images with jpegoptim or pngquant)
- Open In Terminal / Vim (open selected directory in terminal / selected files in Vim)
- Merge Subtitles (merge .srt subtitles into video files)
Also discovered it's very useful to enable the preview panel in Finder (View -> Show Preview or cmd+shift+p) because it has 3 slots for quick action, much faster than going to context menu.
Also for showing output, you can use
osascript -e "display notification \"Message Here!\" with title \"Title Here!\""
The only use I ever get out Automator is basically just recording my actions, and then copying the actions into Script Editor in order to convert the actions to AppleScript.
I wish Swift could replace AppleScript, but that is asking for too much. I dread the day AppleScript is not longer supported. Shortcuts is way too limited in my experience.
You can install your own QuickLook plugins to handle those, and more. I found all the ones I use on GitHub: QLVideo, qlmarkdown/QLCommonMark, qlstephen, etc
It’s weird how hacky macOS feels compared to Linux, where you can get a good idea on how things works due to openness and Windows, due to the good documentation Microsoft offers. In macOS it always feels like you have to be grateful about whatever is allowed and depend on mysterious closed source software.
Everything except for the last part of this is native functionality built into Mac. Automator is an app every Mac ships with and it natively has the ability to put things in your Quick Actions, make folder actions, etc.
The only real hacky part of this is that it is stuck within the "Quick Actions" menu instead of just being part of the dropdown and this app addresses that. But thats a fairly small part of this implementation.
That's exactly what he is referring to. In Windows, you'd either have something documenting that API (to add it in the context menu, not under Quick Actions), or if it is undocumented, you'd still have an idea where to look for it. There would be some sort of API, you'd LoadLibrary, find the symbol, call it with some arguments. Even undocumented, you can kind of rely that it will be there later in some shape or form.
In MacOS, it is really convoluted. Do I dynamically load some bundle? What bundle? Likely they'll put it somewhere else sometime soon.
Of course in principle, there is some API but the way that Apple treats them is very different.
For example, I want to get how many fingers are touching the trackpad right now and the current position of these touches. There are all sorts of things like PinchControllers that need to be initialized and they emit events etc., but nothing to give you the current state of affairs or exactly what you want.
I am confused, I feel like we are talking about different things.
If you look at the page, the difference between the official implementation and this app is that instead of it being under "Quick Actions" in your context menu, it is just right there.
It isnt like Apple doesn't give you a way to put something in your context menu with Automator, they just put it inside Quick Actions. You don't even need to use Automator, just right click in finder, go to quick actions and click customize.
Would it be great if I didnt need it to be stuck under Quick Actions, I mean sure. But except for one minor change (making something 1 less level deep in a menu) this entire workflow is possible without any third party app or "hacks".
Edit: If we want to talk about API's and other things sure. But given the context of this article, I was assuming that the OP was talking about the functionality presented in this article which most of the implementation is Apple provided tooling.
> In MacOS, it is really convoluted. Do I dynamically load some bundle? What bundle? Likely they'll put it somewhere else sometime soon.
In macOS, you'd write a Finder Action Extension[0], which lets users add buttons to Finder's toolbar and context menus.
> In Windows, you'd either have something documenting that API (to add it in the context menu, not under Quick Actions)
As someone who uses both Macs and Windows PCs, I absolutely loathe that this is so common in Windows. Every utility I install wants to add their own items to context menus, and they can do so without my permission. On the Mac, users need to opt-in to allowing your extensions, and they can always go to System Settings and disable them later.
> it is undocumented, you'd still have an idea where to look for it. There would be some sort of API, you'd LoadLibrary, find the symbol, call it with some arguments. Even undocumented, you can kind of rely that it will be there later in some shape or form.
Is using undocumented APIs in Windows common? This sets off my Spidey-sense hard.
If you've been a techy Mac user and don't know about Automator then it's a you problem. It was evangelised quite heavily and has been in its final form for a long time. These are its twilight years as the new-ish Shortcuts system takes over.
On second thoughts, I think the person I replied to was perhaps talking specifically about the (in)ability to put things at the root of the menu. So I apologise if that was the case.
I'm amazed at how hard it is to write a native desktop app in MacOS! Macs didn't originally have a two-button mouse, so it could be context menus are "hacky" because of their late arrival.
if you have the Path Bar visible in Finder you can right-click on the folder name and choose "Copy 'X' as pathname". Works to copy any parent folder name, too.
I assume you might be talking about the Mac app that has not had an update since 2023.
But why do we consider that abandoned? It seems like the kind of thing that if it works, why keep updating it? Now if it broke in a new version of Mac and it wasnt updated, sure we could call it that. But from what I can tell this is not the case.
Do they mean to use Shortcuts instead of Automator? It does seem Apple moved their focus to Shortcuts, which does cover the features Automator has (at least for my use cases, curious to hear the differences and the state of these 2 apps from people more informed)
You know, I always forget the shortcuts has come to Mac. I use it quite a bit on my iPhone but have yet to really explore it on my Mac.
But that is a really good point, I am curious why both continue to exist except for not wanting to break existing Automator... automations? I am not sure what they are called.
Autommator does still have the major functionality (when it works) of being able to record your actions and just do those. Which shortcuts cannot do.
I would bet that it is the "record" functionality keeping it around (beyond just the "multi-year transition" apple said they were doing in 2021), but maybe there are some other power features that are unavailable in shortcuts yet.
I even built my own Mac app which sits in my menubar syncing tags on project folders with the status of projects in a web app I built. Even better that is synced with iCloud so I can access all of those files and tags from my other devices.
I had not considered how else I could improve this situation with context menu options, but now I want to explore how I could use Automator to improve this setup even more.