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

list all files modified today with type "adobe photoshop..." in applescript

我正在为工作中的计费目的创建一个脚本,它可以计算在 运行 当天修改的所有文件,并且类型为 "Adobe Photoshop ..."(例如 "Adobe Photoshop file"、"Adobe Photoshop JPEG file", "Adobe Photoshop TIFF file").

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

到目前为止我有这个:

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 在我的 Snow Leopard 上的使用显得非常缓慢。有更快的方法,通过 shell 命令使用聚光灯。有关详细信息,请参阅 this

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

and kind is "text"and kind contains "text" 在 Finder 搜索中。更多信息 here.