Jump to content

List file metadata


Recommended Posts

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 by Stephen_C
Edited title to reflect renaming of workflow
Link to comment
  • Stephen_C changed the title to List file metadata

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

Link to comment
  • 2 weeks later...

@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
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
  • 2 weeks later...

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
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 by luckman212
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...