列出今天在AppleScript中使用类型"adobe photoshop..."修改的所有文件



>我正在创建一个用于计费目的的脚本,该脚本可以计算运行当天修改的所有文件,并且类型为"Adobe Photoshop..."(例如"Adobe Photoshop 文件"、"Adobe Photoshop JPEG 文件"、"Adobe Photoshop TIFF 文件"(。

我不能只搜索"图像",因为脚本也会列出原始文件(只有当文件保存在 photoshop 中(在办公室修改(时,它才会将类型更改为"Adobe Photoshop ____ 文件"(。

到目前为止,我有这个:

with timeout of (5 * 60) seconds
    set root_fol to (choose folder)
    tell application "Finder"
        set files_ to count ((files of entire contents of root_fol) whose modification date is greater than ((current date)) - 1 * days)
    end tell
    display dialog (files_)
end timeout

但它不查找修改today的文件。相反,它会查找过去 24 小时内修改的文件 - 例如,当您在今天 18:00 运行脚本时,它还将为您提供昨天上次修改但 18:00 之后的文件。(它搜索所有文件,而不仅仅是Photoshop文件(

简而言之,我想模仿进入Finder搜索栏并寻找date modified is today and kind is other: "adobe photoshop"的过程

您需要使用范围。所以你应该像这样搜索午夜到午夜......

set fl to path to downloads folder from user domain as alias
set ds to date string of (current date)
# Today at midnight
set t to date (ds & " 12:00:00 AM")
# Yesterday at midnight
set y to t - 1 * days
tell application "Finder"
    set fc to count ((files of entire contents of fl) whose modification date is greater than y and modification date is less than t)
end tell

顺便说一句,这种对Finder的使用在我的雪豹上显得非常慢。有更快的方法,通过 shell 命令使用聚光灯。有关详细信息,请参阅此处。

编辑:对于您可以使用的文件类型

在"访达"搜索中and kind is "text"and kind contains "text"。更多信息在这里。

最新更新