在applescript中检测文件大小

Detecting file size in applescript

所以我试图在某个文件变大时提醒自己,但我并没有真正在互联网上找到与文件大小相关的任何信息。我知道理论上你可以使用 shell find 命令或类似的命令,但我真的不喜欢将 shell 与 applescript 结合使用。

set theSize to the size of "/Directory/to/my/File"
if theSize > 100000 then
    display notification "This file is really big, you should delete it."
end if

您可以向 Finder、命令信息(已弃用)、AsObjC 的 FileManager 询问某些文件的大小:

tell application "Finder" to set theSize to size of ("/Directory/to/my/File" as POSIX file as alias)
-- set theSize to size of (info for "/Directory/to/my/File")

if theSize > 100000 then
    display notification "This file is really big, you should delete it."
end if