Stephen_C Posted March 1, 2023 Share Posted March 1, 2023 (edited) Introduction This rather simple workflow acts as a Universal Action on a single selected file to provide access to that file's metadata in Terminal. You can choose whether to see merely the Universal Type Identifiers ("UTI") for the file or to see all of the metadata. See https://developer.apple.com/documentation/uniformtypeidentifiers for an Apple introduction to UTI. In Alfred you may need to know: UTI for a file or files when, for example, in the Basic Setup of a File Filter; or additional metadata information to complete the Fields tab of a File Filter. Usage Select a file in Finder (or in Alfred's search results), use your Universal Action hotkey and run List file metadata in Terminal on the file. You will be given the choice of seeing only the UTI (the default) or all metadata. Here is the GitHub download link. Stephen Edited March 1, 2023 by Stephen_C Edited title to reflect renaming of workflow Link to comment
Stephen_C Posted March 1, 2023 Author Share Posted March 1, 2023 I have released version 2.0. With apologies for the very quick update, this version substantially revised the workflow and improved the output of the UTI information. All output is now copied to the clipboard rather than inflicting upon you the crudity of the Terminal interface (with apologies to those who are fans of it 😀). Stephen pixelgeek 1 Link to comment
pixelgeek Posted March 1, 2023 Share Posted March 1, 2023 Wow! For someone who talks of the "crudity of the Terminal interface" you know your way around it 🙂 Just a note, its a very helpful tool but it won't fix the issue I reported yesterday. I am going to dig around and see if I can come up with something similar that will help solve that issue. Link to comment
Stephen_C Posted March 2, 2023 Author Share Posted March 2, 2023 Version 2.1 updates the Universal Action prompt to mirror the name of workflow. Stephen Link to comment
vitor Posted March 2, 2023 Share Posted March 2, 2023 @Stephen_C Was making this ready for the Gallery but noticed something: on the bottom Run Script you have Echo File: $1. While that works, I suspect it will break for the minority of people on case-sensitive file systems. The correct name of the command is echo, all lowercase. Link to comment
Stephen_C Posted March 2, 2023 Author Share Posted March 2, 2023 @vitor corrected in version 2.11: apologies for the error! Stephen Link to comment
vitor Posted March 2, 2023 Share Posted March 2, 2023 Was about to push the changes when I noticed that the dialog still mentions the Terminal! Link to comment
Stephen_C Posted March 2, 2023 Author Share Posted March 2, 2023 (edited) Corrected - but, rather naughtily, without updating the release version (i.e., version 2.11 should now be correct). Stephen Edited March 2, 2023 by Stephen_C Link to comment
vitor Posted March 2, 2023 Share Posted March 2, 2023 I think you readded the old one, that one still mentions the Terminal in the dialog. Link to comment
Stephen_C Posted March 2, 2023 Author Share Posted March 2, 2023 Not sure who is more fed up with this at present: you or me. Have repeated exercise and checked download twice and it now seems OK to me. Stephen Link to comment
vitor Posted March 2, 2023 Share Posted March 2, 2023 2 minutes ago, Stephen_C said: Not sure who is more fed up with this at present: you or me. That made me laugh! Coincidentally I had just rechecked and finished the update. Will be available later today at http://alfred.app/workflows/stephenc/list-file-metadata/. Link to comment
sepulchra Posted March 10, 2023 Share Posted March 10, 2023 @Stephen_C I love this workflow and I suddenly have a specific need to just pull this metadata field from the MDLS: kMDItemFSCreatorCode I can see how you are using regex to get rid of the unwanted metadata in your workflow but i'm not so hot at regex. Would you be game to help me with that bit of regex to display that bit of metadata versus UTI? Thanks! Link to comment
vitor Posted March 10, 2023 Share Posted March 10, 2023 Just now, sepulchra said: i'm not so hot at regex. If you understand some of it, I recommend https://regex101.com. It lets you experiment with a regex live against some text. Link to comment
sepulchra Posted March 10, 2023 Share Posted March 10, 2023 (edited) Thanks! I'll put myself through some trial and error .... and pain and suffering. Edited March 10, 2023 by sepulchra Link to comment
sepulchra Posted March 10, 2023 Share Posted March 10, 2023 and i sorted it. I guess never to old to learn new things. Link to comment
Stephen_C Posted March 10, 2023 Author Share Posted March 10, 2023 56 minutes ago, sepulchra said: Would you be game to help me with that bit of regex to display that bit of metadata versus UTI? Apologies for the slight delay in responding. First, I find regex a nightmare and usually have to spend ages on the site recommended by Vitor before I can get any specific piece of regex to work. Second, more reassuringly, my workflow didn't use regex but, rather, a little piece of shell script (also something of a novelty for me). The only real thing I had to spend time with was the sed command—which I had to experiment with for some time and which I used merely to tidy the final result. I suspect by simply replacing kMDItemContentTypeTree in my workflow with kMDItemFSCreatorCode - and possibly a little fiddling with the sed command - you'll quite easily obtain what you need (althought it seems you may have already discovered that!). If there were a more general demand to isolate other pieces of metadata I might consider updating the workflow to provide for that. Stephen Link to comment
sepulchra Posted March 10, 2023 Share Posted March 10, 2023 Thank you. This is incredibly helpful. Link to comment
Dellu Posted March 20, 2023 Share Posted March 20, 2023 This is not working for me. It simply copies the file to the clipboard; not the attributes. Link to comment
Stephen_C Posted March 20, 2023 Author Share Posted March 20, 2023 Please run the workflow on a selected file and post here the output of the Debugger window. There's no real reason why the workflow would not work as there are no dependencies. It may also be helpful to confirm what macOS and Alfred versions you are using. Stephen Link to comment
luckman212 Posted March 20, 2023 Share Posted March 20, 2023 (edited) On 3/10/2023 at 2:56 PM, sepulchra said: I suddenly have a specific need to just pull this metadata field from the MDLS: kMDItemFSCreatorCode I can see how you are using regex to get rid of the unwanted metadata in your workflow but i'm not so hot at regex. Maybe I'm late to this party but, just in case: @sepulchra you don't need regex to extract a single piece of metadata as a plain string. You can use e.g. mdls -raw -name kMDItemFSCreatorCode /path/to/file Edited March 20, 2023 by luckman212 sepulchra and vitor 1 1 Link to comment
sepulchra Posted March 20, 2023 Share Posted March 20, 2023 @luckman212Thank you! You are right and I figured that out shortly after I dug around a bit. I dug into the @Stephen_C's script and tweaked it for my own purposes which looks like this. Link to comment
luckman212 Posted March 20, 2023 Share Posted March 20, 2023 @sepulchra Nice. One more small comment: in your example script, you define a query variable, but your script never uses it. Link to comment
sepulchra Posted March 20, 2023 Share Posted March 20, 2023 Thanks! I usually fumble my way through. Link to comment
Stephen_C Posted March 20, 2023 Author Share Posted March 20, 2023 6 minutes ago, sepulchra said: I usually fumble my way through You are not the only one: join the club! 😀 Stephen Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now