Hello.
Mavericks no longer contains the genericIcon I used in the script in post #9, so here is a script with an alternative.
-- http://macscripter.net/edit.php?id=154143
-- New faster way to create record by Nigel Garvey
-- http://macscripter.net/viewtopic.php?id=39265
-- SPOTLIGHT INFO FOR SELECTED ITEMS
-- PARTS ©1998 Sal Soghoian, Apple Computer
-- 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).
New code converts mdls info to a list directly
*)
property metaList : missing value
global genericIcon
property ScriptTitle : "Spotlight Meta Data for Items info"
set genericIcon to a reference to file ((path to library folder from system domain as Unicode text) & "CoreServices:CoreTypes.bundle:Contents:Resources:ToolbarInfo.icns")
set infoIcon to a reference to file ((path to library folder from system domain as text) & "CoreServices:CoreTypes.bundle:Contents:Resources:AlertNoteIcon.icns")
set idOfFrontApp to getfrontAppId()
set ReportText to ""
set failed to false
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
try
set startPath to target of its Finder window 1 as alias
on error
set starpath to path to desktop folder
end try
end tell
if selCount = 0 then
tell application "SystemUIServer"
activate
try
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)
on error
set failed to true
end try
end tell
set selCount to count selected_items_list
if ((count of the selected_items_list) = 0) or failed then
alertDialog({aTextMessage:"No files or applications are selected.", aTextTitle:my ScriptTitle, timeInSecs:300, btnAsList:{"Ok"}, iconAsFileRef:infoIcon, bundleIdOfFrontApp:idOfFrontApp})
abortNicely({bundleIdFrontApp:idOfFrontApp})
end if
set last_item to the last item of the selected_items_list as text
end if
set failed to false
tell application "SystemUIServer"
activate
try
set outputType to button returned of (display dialog "Please choose form of output" with title ScriptTitle buttons {"Cancel", "Report", "Dialogs"} cancel button 1 default button 3 with icon genericIcon)
on error
set failed to true
end try
end tell
if failed then abortNicely({bundleIdFrontApp:idOfFrontApp})
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
set metaList to Rec2UserKeyValues(metaRec)
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
repeat with i from 1 to (count metaList)
set ReportText to ReportText & item 1 of item i of my metaList & ": "
if class of item 2 of item i of my metaList = 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 metaList 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 metaList & return
end if
end repeat
if outputType is "Dialogs" then
set the clipboard to ReportText
if contents of 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 application "SystemUIServer"
activate
display dialog ReportText with title ScriptTitle buttons the button_list default button (the last item of the button_list) with icon genericIcon
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 not failed then
alertDialog({aTextMessage:e & " " & N, aTextTitle:my ScriptTitle, timeInSecs:300, btnAsList:{"Ok"}, iconAsFileRef:infoIcon, bundleIdOfFrontApp:idOfFrontApp})
abortNicely({bundleIdFrontApp:idOfFrontApp})
end if
end try
on metaDataRecord for fp
-- http://macscripter.net/edit.php?id=154143 NG
-- Ensure that we have a quoted POSIX path to the file.
if (fp's class is text) then
if (fp does not start with "'/") then
if (fp does not start with "/") then set fp to POSIX path of fp
set fp to quoted form of fp
end if
else
set fp to quoted form of POSIX path of (fp as alias)
end if
-- Get the metadata text and edit it almost to compilability. Mark date entries with unlikely tags. ;)
set rs to do shell script "mdls " & fp & " | sed -Ee 's| *=|:|' -e 's|^ +([^\"][a-zA-Z]*[^\"])$|\"\\1\"|' -e 's|\"?([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [+-][0-9]{4})\"?|<McUsr>\\1</McUsr>|' -e 's|\\($|{ ¬|' -e 's|^\\)|}|' -e 's|,$|, ¬|' -e 's|([^¬])$|\\1, ¬|'"
if ((count rs) > 0) then
-- Append braces for the record representation.
set rs to "{" & text 1 thru -4 of rs & "}"
set astid to AppleScript's text item delimiters
-- Zap any stray commas at the ends of lists.
set AppleScript's text item delimiters to ", ¬" & return & "}"
set rs to rs's text items
set AppleScript's text item delimiters to " ¬" & return & "}"
set rs to rs as text
-- Replace the ISO dates with AppleScript dates transposed to the computer's time zone and coerced to text as per the local preferences. Requires AS 2.1 (Snow Leopard) or later for the multiple TIDs.
set AppleScript's text item delimiters to {"<McUsr>", "</McUsr>"}
set rs to rs's text items
repeat with i from 2 to (count rs) by 2
set dateString to item i of rs
set item i of rs to "date \"" & getASLocalDate(dateString) & "\""
end repeat
set AppleScript's text item delimiters to ""
set rs to rs as text
set AppleScript's text item delimiters to astid
-- Return the "compiled" record.
return (run script rs)
else
return {}
end if
end metaDataRecord
-- Return a local AppleScript date from a given ISO date/time with time-zone displacement.
on getASLocalDate(ISODate)
-- Get the ISO date/time as as AppleScript date object. (The date object will be reused for different purposes below to save multiple calls to 'current date'.)
tell (current date) to set {day, {year, its month, day, its hours, its minutes, its seconds}, ASDate} to {1, words 1 thru 6 of ISODate, it}
-- Subtract the time-zone displacement to transpose to GMT.
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to space
tell (text item -1 of ISODate) as integer to set ASGMTDate to ASDate - (it div 100 * hours + it mod 100 * minutes)
set AppleScript's text item delimiters to astid
-- Subtract the Unix era start from the GMT date to get the number of seconds since then.
tell ASDate to set {day, month, year, time} to {1, 1, 1970, 0}
set eraTime to ASGMTDate - ASDate
-- Coerce this figure to text in straight decimal notation.
if (eraTime > 99999999) then
set eraTime to (eraTime div 100000000 as text) & text 2 thru 9 of (100000000 + eraTime mod 100000000 as integer as text)
else if (eraTime < -99999999) then
set eraTime to (eraTime div 100000000 as text) & text 3 thru 10 of (-100000000 + eraTime mod 100000000 as integer as text)
else
set eraTime to eraTime as text
end if
-- Run the figure through "date" to get the corresponding machine-local date/time and convert to AS.
do shell script ("date -r " & eraTime & " '+%Y %m %d %H %M %S'")
tell ASDate to set {year, its month, day, its hours, its minutes, its seconds} to words of result
return ASDate
end getASLocalDate
on getfrontAppId() -- Returns bundleid of active app
local frontappId
set frontappId to ""
tell application "System Events"
set frontappId to bundle identifier of first application process whose frontmost is true
end tell
return frontappId
end getfrontAppId
on abortNicely(R) -- Returns Nothing
tell application "System Events" to tell application process id (bundleIdFrontApp of R)
key down «constant epmdctlm»
key code 118
key up «constant epmdctlm»
end tell
error number -128
end abortNicely
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
on alertDialog(R) -- Returns Nothing
-- R : {aTextMessage:theMessage,aTextTitle:thetitle,timeInSecs:lenToTimeout,btnAsList:theButton,iconAsFileRef:theIcon,bundleIdOfFrontApp:frontappId}
local res, failed, e, N
set failed to false
tell application "SystemUIServer"
activate
try
if (iconAsFileRef of R) is null then
set res to button returned of (display dialog (aTextMessage of R) with title (aTextTitle of R) giving up after (timeInSecs of R) buttons (btnAsList of R) default button 1)
else
set res to button returned of (display dialog (aTextMessage of R) with title (aTextTitle of R) giving up after (timeInSecs of R) buttons (btnAsList of R) default button 1 with icon (iconAsFileRef of R))
end if
if res = "" then set failed to true
on error e number N
set failed to true
end try
end tell
if failed is true then
abortNicely({bundleIdFrontApp:(bundleIdOfFrontApp of R)}) -- Returns Nothing
end if
return
end alertDialog