【问题标题】:How does one extract info from the 'More Info' of finder?如何从 finder 的“更多信息”中提取信息?
【发布时间】:2019-08-31 08:24:06
【问题描述】:

我一直在尝试从 finder 的“更多信息”部分中提取关键字。我已经能够从“常规”部分中提取数据,但无法找到从“更多信息”部分中提取数据的方法。以下是我为“常规”部分提供的一些代码

-- 代码版本 1--

on run
tell application "Finder"
    set selectedItem to (item 1 of (get selection))
    set infoList to {}
    copy ("Displayed Name: " & displayed name of selectedItem) to end of infoList
    copy ("Kind: " & kind of selectedItem) to end of infoList
    copy ("Size: " & size of selectedItem & " (" & physical size of selectedItem & ")") to end of infoList
    copy ("Where: " & (selectedItem as alias) as string) to end of infoList
    copy ("Created: " & creation date of selectedItem) to end of infoList
    copy ("Modified: " & modification date of selectedItem) to end of infoList
    copy ("Name & Extension: " & name of selectedItem) to end of infoList
    copy ("Locked: " & locked of selectedItem) to end of infoList
    copy ("Comments: " & comment of selectedItem) to end of infoList
    copy ("Owner: " & owner of selectedItem) to end of infoList
    copy ("Group: " & group of selectedItem) to end of infoList
end tell
set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
set infoAsString to infoList as string
set AppleScript's text item delimiters to od
set the clipboard to infoAsString
return infoAsString
end run

-- 代码版本 2--

    tell application "Image Events"
        -- start the Image Events application
        launch
        -- open the image file
        set this_image to open (inputPath & "HighRes/" & fname & ".tif")
        -- extract the value for the metadata tag
        tell this_image
            set the imgDescp to the value of metadata tag "description"
        end tell
        -- purge the open image data
        close this_image
    end tell

【问题讨论】:

    标签: macos automation applescript finder


    【解决方案1】:

    您可以在 Spotlight 元数据存储中找到大部分(如果不是全部),例如:

    do shell script “mdls “ & quoted form of “/posix/path/to/file”
    

    可以通过指定属性名称来提取单个项目 - 请参阅mdls man page

    【讨论】:

    • 执行 shell 脚本 "mdls -name kMDItemKeywords " & 'Path' 的引用形式
    猜你喜欢
    • 2013-04-27
    • 2016-02-25
    • 1970-01-01
    • 2018-06-29
    • 1970-01-01
    • 2011-09-25
    • 2023-03-28
    • 2020-10-17
    • 2020-06-30
    相关资源
    最近更新 更多