Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: A Finder plug-in to access file metadata Desktop
Tiger only hintI put together a Finder plug-in to easily access file metadata (in response to Mark Hunte's hint.) After installing, you can control-click on files and select this script from the new "Automator" menu. The results are displayed in Terminal windows.

You can find instructions, screenshots, and the workflow to download right here.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[14,497 views]  

10.4: A Finder plug-in to access file metadata | 15 comments | Create New Account
Click here to return to the '10.4: A Finder plug-in to access file metadata' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: A Finder plug-in to access file metadata
Authored by: Nyhthawk on Jun 27, '05 01:08:13PM

You don't need the first action in the workflow, Get Selected Finder Items. The selected items are automatically passed to a workflow when it is executed from the Finder's contextual menu, or used as an Image Capture or Print Workflow plugin.



[ Reply to This | # ]
10.4: A Finder plug-in to access file metadata
Authored by: Nyhthawk on Jun 27, '05 01:09:12PM

You don't need the first action in the workflow, Get Selected Finder Items. The selected items are automatically passed to a workflow when it is executed from the Finder's contextual menu, or used as an Image Capture or Print Workflow plugin.

For more info, visit: http://automator.us



[ Reply to This | # ]
View the metadata in the Finder
Authored by: Nyhthawk on Jun 27, '05 01:20:52PM
BTW, you don't need to open the Terminal app to view the metadata. Use the display dialog command to view the data in the Finder! Change the script in the AppleScript action to this:

on run {input, parameters}
	repeat with i in input
		set this_script to "mdls " & quoted form of (POSIX path of (i as alias))
		set this_result to do shell script this_script
		display dialog this_result
	end repeat
	return input
end run


[ Reply to This | # ]
View the metadata in the Finder
Authored by: simonpie on Jun 28, '05 09:52:09AM

I like the idea of a dialog, but the formating is not very good (many items are on multiple lines) and in the end, it does not fit in a 17" power book screen.

Simon



[ Reply to This | # ]
10.4: A Finder plug-in to access file metadata
Authored by: adrianm on Jun 27, '05 02:19:56PM
Hasn't this been run a few times before? Mine is:

on run {input, parameters}
  tell application "Finder"
    repeat with this_item in input
      set ppath to POSIX path of this_item
      do shell script "mdls " & quoted form of ppath & " | open -f"
    end repeat
  end tell
end run
A bit verbose, but does give you chance to copy the resulting data.

[ Reply to This | # ]
10.4: A Finder plug-in to access file metadata
Authored by: magnamous on Jun 27, '05 07:57:48PM
I made my own workflow that uses a combination of the applescript from the post by Nyhthawk and the post by adrianm (I'm not a coder, so the version I cobbled together was easier for me to understand). My version puts the metadata for each file selected in the Finder into a separate text file in TextEdit. I wanted (but couldn't figure out how) to get all of the text files to be combined into one big text file afterward. If anyone can figure out how to do that, I'd appreciate it. Here's my workflow:

Get Selected Finder Items
Run Applescript:

on run {input, parameters}
repeat with i in input
do shell script "mdls " & quoted form of (POSIX path of (i as alias)) & " | open -f"
end repeat
return input
end run


[ Reply to This | # ]

10.4: A Finder plug-in to access file metadata
Authored by: russs on Jun 28, '05 02:24:50AM
This code will combine all the results into just one list as requested:
on run {input, parameters}
	tell application "Finder"
		set ppath to "" --empty string to initialize variable because below we set it to itself and a file path from the list
		repeat with this_item in input
		set ppath to ppath & quoted form of (POSIX path of this_item) & " " --quoted space character to separate paths as they get appended one at a time
		end repeat
		do shell script "mdls " & ppath & " | open -f" --now ppath contains all selected files' paths
	end tell
end run


[ Reply to This | # ]
10.4: A Finder plug-in to access file metadata
Authored by: magnamous on Jun 28, '05 05:37:25PM
Well, for some reason that script didn't work for me. When I pasted it in, I got this error:

Can't make «class docf» "Picture 1.png" of «class cfol» "Desktop" of «class cfol» "magnamous" of «class cfol» "Users" of «class sdsk» of application "Finder" into the expected type. (-1700)

But I modified the script and integrated it with the other versions and came up with this, which seems to work well:


on run {input, parameters}
	set ppath to "" --empty string to initalize variable before we manipulate it
	repeat with i in input
		set ppath to ppath & quoted form of (POSIX path of (i as alias)) & " "
		--quoted space character to separate paths as they get appended
	end repeat
	do shell script "mdls " & ppath & " | open -f"
	-- run the command with all of the files' paths
	return input
end run

Thanks for helping modify this script to suit my preferences!

[ Reply to This | # ]

10.4: A Finder plug-in to access file metadata
Authored by: gmehl on Jun 28, '05 12:38:23PM

Hopefully this isn't too far off topic.... but does anyone know if there is a keyword or something else in metadata that indicates whether a PDF file is text searchable?

I have a lot of articles that are in pdf format but are images (someone scanned them and then didn't "capture OCR" the text") so they are not searchable with spotlight excepting their filename.

Suggestions? Thanks....




[ Reply to This | # ]
10.4: A Finder plug-in to access file metadata
Authored by: magnamous on Jun 28, '05 05:41:20PM

I don't know if there is, but given your situation it seems pretty irrelevant. If the PDF files are just images, they aren't going to be text-searchable because they have no text.

If you don't have OCR software and you really, really want them to be text-searchable, I suppose you could get around this by typing up the entire document yourself and pasting the text into the spotlight comments. That's a pretty ugly workaround, though.



[ Reply to This | # ]
10.4: A Finder plug-in to access file metadata
Authored by: gmehl on Jun 28, '05 10:02:05PM

I have a feeling there are many academics and students in this situation .... but maybe not yet.

Some additional information as to my situation....acrobat has "capture page" which is effectively an OCR of the image... which then becomes searchable text. Also Omnipage will do this.... but given that I have 2000x pdf files (journal articles) that are text searchable, and another 1000 that are just images in pdf format... wondering if there is an underlying metadata tag that indicates whether the documents first 100 words have been indexed by spotlight... if there is that would be great.... I thought it might reside as a metadata tag.... but maybe not.

Thanks for any additional suggestions.

G



[ Reply to This | # ]
10.4: A Finder plug-in to access file metadata
Authored by: magnamous on Jun 29, '05 02:00:37AM
I have a feeling there are many academics and students in this situation .... but maybe not yet.
I'm sorry - I wasn't trying to suggest that your situation is irrelevant. I thought that your goal was to be able to content-search these files, so a flag as to whether they were text-searchable or not seemed irrelevant.
Some additional information as to my situation....acrobat has "capture page" which is effectively an OCR of the image... which then becomes searchable text. Also Omnipage will do this.... but given that I have 2000x pdf files (journal articles) that are text searchable, and another 1000 that are just images in pdf format... wondering if there is an underlying metadata tag that indicates whether the documents first 100 words have been indexed by spotlight... if there is that would be great.... I thought it might reside as a metadata tag.... but maybe not.
I've tried to figure out a way to search for PDF files that have any searchable text content, but
  1. There isn't a "text-searchable" metadata tag for PDFs in OS X by default that I am aware of (read this to find out how to make your own customized metadata tag - make sure to read the whole page so you don't get yourself into trouble down the road)

  2. I don't know enough about Spotlight syntax to know how to create a completely wildcard query (that is, one which searches for any text content). If anybody can improve on my solution, please do!

I've created a bit of a kludge that might get you what you want, but it'll take a while.

  1. First, you have to create some smart folders. Create a new smart folder. Set it up to search the folder or drive where the PDFs are stored, and to have 2 search criteria: Kind and Contents. Select PDF in Kind and type the letter "a" (no quotes) in Contents. (Alternately, you can choose "Other…" from the search criteria menu and search for rawquery (learn more about spotlight query syntax here). Select it as the search criterion. Put this in the text box field for that search: (kMDItemContentTypeTree == "com.adobe.pdf") && (kMDItemTextContent == "*a*"cd) - repeat this with other folders, replacing "*a*"cd with "*b*"cd, "*c*"cd, and so on.)

  2. You have to create 25 more Smart Folders like the last one - each with a different letter of the alphabet. If you want to include PDFs that might only have numbers as text, make smart folders that search for individual numbers in the Contents field. Make sure to set each one to search the folder or drive where the PDFs are stored.

  3. Once you've done that, you should be able to open each Smart Folder, and it'll show you all of the PDF files that have that particular letter or number in it's text contents. At this point, you can highlight all of the PDFs in the Smart Folder and hit Command-Option-I to get the Inspector window. In the Spotlight Comments section, type "Text-searchable" (no quotes). Repeat this for each of the smart folders that you created.

  4. Now, all of your PDFs that have text in them should have "Text-searchable" in the Spotlight Comments metadata tag. At this point, you should be able to trash all of those single-letter and single-number Smart Folders and replace them with only two: one which looks for "Text-searchable" in your giant folder of PDFs, and one that looks for files that do not have "Text-searchable" anywhere in them. If you prefer, you could also tag all of the PDFs in the not-text-searchable Smart Folder with the tag "Not-text-searchable" so that they're easier to find (then, of course, change the not-text-searchable Smart Folder's parameters to make use of that change).
Whew! Quite a lot of work. I hope I've explained it all correctly (and I hope it works!).

[ Reply to This | # ]
10.4: A Finder plug-in to access file metadata
Authored by: gmehl on Jun 29, '05 02:50:22PM

I'm impressed and very thankful. I'll give it a try right now and report back as to whether this works.... quite a workaround! and I really appreciate your effort and creative spirit. I really wish I had any programming background.

Thanks again.

G



[ Reply to This | # ]
10.4: A Finder plug-in to access file metadata
Authored by: gmehl on Jun 29, '05 03:14:13PM

A follow up after having used this suggestion:

Given that most of my documents (if not all of them) have the letter a in them somewhere, I only made one smart folder with content "a" -- worked like a charm.

On your excellent suggestion of adding comment, I identified an automator workflow that enables me to add "searchable" in the spotlight comments of multiple selected items....it can be found here: http://www.automatorworld.com/2005/05/03/add-spotlight-comments/

Thanks again.



[ Reply to This | # ]
10.4: A Finder plug-in to access file metadata
Authored by: arverni on Apr 30, '10 08:46:39AM

I found this very useful, but does anyone know how to search for a specific metadata property, e.g. 'KMDitemID' ?



[ Reply to This | # ]