Applescript 检查文件夹是否为真
在下面的脚本中,我尝试通过检查来确定输入的路径是否指向文件夹:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试删除
tell application "Finder"
和end Tell
行。Try removing the lines
tell application "Finder"
andend tell
.