------------------------------------------------------------------------------------------------
try
# Obtain the Finder selection
tell application "Finder"
set sel to selection as alias list
if sel ≠ {} then
set fSel to first item of sel
end if
end tell
set posixPath to quoted form of POSIX path of fSel
set cmd to "mdls -name kMDItemKeywords " & posixPath
set kMDItemKeywords to do shell script cmd without altering line endings
set kMDItemKeywords to do shell script "perl -ne 's/^ +//g; print' <<< " & ¬
quoted form of kMDItemKeywords without altering line endings
set kMDItemKeywords to do shell script "perl -0777 -wlne 'if (m/[^\\(]+\\(
\\s*([^)]+)/ims) {print \"$1\"}' <<< "
& ¬ quoted form of kMDItemKeywords without altering line endings
set kMDItemKeywords to do shell script "perl -wnle 's/\"//g; print' <<< " & ¬
quoted form of kMDItemKeywords without altering line endings
set kMDItemKeywords to do shell script "perl -0777 -wnle 's/\\s+\\Z//g; print' <<< " & ¬
quoted form of kMDItemKeywords without altering line endings
set kMDItemKeywords to paragraphs of kMDItemKeywords
set cmd to "mdls \\
-name kMDItemDescription \\
-name kMDItemFSCreationDate \\
-name kMDItemHeadline \\
-name kMDItemPixelHeight \\
-name kMDItemPixelWidth \\
-name kMDItemTitle " & posixPath
set infoReco to do shell script cmd without altering line endings
set infoReco to do shell script "perl -wnle 's/\"//g; print' <<< " & ¬
quoted form of infoReco without altering line endings
set infoReco to do shell script "perl -0777 -wnle 's/[()]//g; print' <<< " & ¬
quoted form of infoReco without altering line endings
set infoReco to do shell script "perl -0777 -wnle 's/\\s+\\Z//g; print' <<< " & ¬
quoted form of infoReco without altering line endings
set infoReco to paragraphs of infoReco
set AppleScript's text item delimiters to "= "
repeat with i in infoReco
set contents of i to text item 2 of i
end repeat
set kMDItemDescription to item 1 of infoReco
set kMDItemFSCreationDate to item 2 of infoReco
set kMDItemHeadline to item 3 of infoReco
set kMDItemPixelHeight to item 4 of infoReco
set kMDItemPixelWidth to item 5 of infoReco
set kMDItemTitle to item 6 of infoReco
on error errMsg number errNum
set {cr, sep} to {return, "------------------------------------------"}
set e to sep & cr & "Error: " & errMsg & cr & sep & cr & "Error Number: " & errNum & cr & sep
beep
display dialog e
end try