Applescript 检查文件夹是否为真

发布于 2024-12-28 12:24:32 字数 1022 浏览 2 评论 0原文

在下面的脚本中,我尝试通过检查来确定输入的路径是否指向文件夹:

folder of file_info -> should return true/false

但是在尝试此操作时,脚本给出错误并停止。

但其他值工作得很好例如:

size of file_info -> return size incase of folder its "missing value"

有人知道为什么这不起作用?我见过人们使用它的其他脚本,但似乎没有人收到此错误

on log_event(themessage)
            set theLine to (do shell script "date  +'%Y-%m-%d %H:%M:%S'" as string) & " " & themessage
            do shell script "echo " & theLine & " >> ~/Library/Logs/tvshowscript-events-test.log"
        end log_event

        tell application "Finder"

            set str to "Macintosh HD:Users:"

            set the_item to str as alias

            set file_info to get info for the_item

            my log_event("-------------- " & size of the file_info)
            my log_event("-------------- " & kind of the file_info)
            my log_event("-------------- " & folder of the file_info)   

        end tell

in the below script i trying to determine if the inputed path points to a folder by checking:

folder of file_info -> should return true/false

but when trying this the script gives and error and stops.

but other values work fine example:

size of file_info -> return size incase of folder its "missing value"

someone knows why this doest work? i have seen other scripts where people use it, but no one seems to get this error

on log_event(themessage)
            set theLine to (do shell script "date  +'%Y-%m-%d %H:%M:%S'" as string) & " " & themessage
            do shell script "echo " & theLine & " >> ~/Library/Logs/tvshowscript-events-test.log"
        end log_event

        tell application "Finder"

            set str to "Macintosh HD:Users:"

            set the_item to str as alias

            set file_info to get info for the_item

            my log_event("-------------- " & size of the file_info)
            my log_event("-------------- " & kind of the file_info)
            my log_event("-------------- " & folder of the file_info)   

        end tell

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风流物 2025-01-04 12:24:32

尝试删除 tell application "Finder"end Tell 行。

Try removing the lines tell application "Finder" and end tell.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文