Hello!
Select some files in finder, run the script, and obtain the metadata attributes for the file(s).
The metadata attributes may vary with the filetype, and this script reflects that.
It is all stolen, and compiled by me, which is the spelled compilare in latin and means plunder!
-- http://macscripter.net/viewtopic.php?id=39265
-- SPOTLIGHT INFO FOR SELECTED ITEMS
-- PARTS ©1998 Sal Soghoian, Apple Computer
-- PARTS © yiam-jin-qui http://macscripter.net/viewtopic.php?id=36842
-- Parts © 2012 McUsr I'd rather have you referring to this post at Macscripter.net http://macscripter.net/edit.php?id=154116
-- than posting it elsewhere!
(*
Compiled By McUsr 09/08/12:
Based upen INFO FOR SELECTED Items, uses mouramartins convert mdlsinfo (spotlight metadata to list).
*)
property recIdList : missing value
property genericIcon : a reference to file ((path to library folder from system domain as Unicode text) & "CoreServices:CoreTypes.bundle:Contents:Resources:GenericEditionFileIcon.icns")
property appTitle : "Spotlight Meta Data for Items info"
set ReportText to ""
try
tell application "Finder"
activate
set selected_items_list to (get selection) as alias list
set selCount to count selected_items_list
if selCount Ăąâ° 0 then set last_item to the last item of the selected_items_list as text
set startPath to target of its Finder window 1 as alias
end tell
if selCount = 0 then
tell me
activate
set the selected_items_list to (choose file with prompt "Choose the files or folders you want to see info for for" default location startPath with multiple selections allowed)
if the (count of the selected_items_list) is 0 then
with timeout of 900 seconds
beep
display dialog "No files or applications are selected." buttons {"Cancel"} default button 1
end timeout
end if
set last_item to the last item of the selected_items_list as text
end tell
end if
tell me
activate
try
set outputType to button returned of (display dialog "Please choose form of output" with title appTitle buttons {"Cancel", "Report", "Dialogs"} cancel button 1 default button 3 with icon genericIcon)
on error
beep
error number -128
end try
end tell
repeat with this_item in the selected_items_list
if outputType is "Dialogs" then
set ReportText to ""
end if
tell application "Finder" to set item_name to name of this_item
set filepath to quoted form of POSIX path of (this_item as alias)
set metaRec to metaDataRecord for filepath
if outputType is "Report" then
set ReportText to ReportText & return & "==================================" & return & "Name: " & item_name & return
else
set ReportText to ReportText & return & "Name: " & item_name & return
end if
-- set recIdList to get user property names metaRec
set my recIdList to Rec2UserKeyValues(metaRec)
repeat with i from 1 to (count recIdList)
set ReportText to ReportText & item 1 of item i of my recIdList & ": "
if class of item 2 of item i of my recIdList = list then
set oltids to AppleScript's text item delimiters
set AppleScript's text item delimiters to "\" , \""
set tmpTxt to item 2 of item i of my recIdList as text
set AppleScript's text item delimiters to oltids
set ReportText to ReportText & "{ \"" & tmpTxt & "\" }" & return
else
set ReportText to ReportText & item 2 of item i of my recIdList & return
end if
end repeat
if outputType is "Dialogs" then
set the clipboard to ReportText
if this_item is the last_item or selCount is 1 then
set the button_list to {"Done"}
else
set the button_list to {"Cancel", "Next"}
end if
-- display the information
with timeout of 900 seconds
tell me
activate
display dialog ReportText with title appTitle buttons the button_list default button (the last item of the button_list)
end tell
end timeout
end if
end repeat
if outputType is "Report" then
tell application "TextEdit"
activate
make new document at the front
set text of front document to "F i l e i n f o r m a t i o n " & return & ReportText
end tell
end if
on error e number n
if n is not -128 then
display dialog "error : " & e & n
end if
end try
to metaDataRecord for pxFilepath
-- mouramartins Macscripter.net http://macscripter.net/viewtopic.php?id=39249
local rs, prs, k, islist, p, x, i
set islist to false
set rs to (do shell script "mdls " & pxFilepath)
set prs to {}
repeat with k from 1 to count of paragraphs of rs
set p to paragraph k of rs
if islist then
if text 1 of p is ")" then
set islist to false
set x to x & "}"
try
set prs to prs & (run script "{" & x & "}")
end try
else
set x to x & p
end if
else
set i to offset of "=" in p
if i > 1 then
set x to (text 1 thru (i - 1) of p) & ":"
if text (i + 2) of p = "(" then
set x to x & "{"
set islist to true
else
set t to text (i + 2) thru -1 of p as text
try
set prs to prs & (run script "{" & x & t & "}")
on error
set prs to prs & (run script "{" & x & "\"" & t & "\"" & "}")
end try
end if
end if
end if
end repeat
return prs
end metaDataRecord
on Rec2UserKeyValues(recAny)
-- http://macscripter.net/viewtopic.php?id=36842 yiam-jin-qui
-- USE THE CLIPBOARD TO MAKE THE RECORD KEYS LEGIBLE
set the clipboard to recAny
set recLegible to (the clipboard as record)
set lngPairs to count of (recAny as list)
if lngPairs < 1 then return {}
-- COLLECT ANY USER-DEFINED KEY-VALUE PAIRS
set lstKeyValue to {}
try
set lstUser to list of recLegible
on error
display dialog (do shell script "osascript -e 'the clipboard as record'") buttons "OK" default button 1 with title "Contents of record"
return {}
end try
repeat with i from 1 to (length of lstUser) - 1 by 2
set end of lstKeyValue to {item i of lstUser, item (i + 1) of lstUser}
end repeat
-- IF ANY PAIRS ARE MISSING, TRY SOME SYSTEM-DEFINED KEYNAMES
if (count of lstKeyValue) < lngPairs then
try
set beginning of lstKeyValue to {"Date", date of recAny}
end try
try
set beginning of lstKeyValue to {"Name", name of recAny}
end try
end if
lstKeyValue
end Rec2UserKeyValues