我正在尝试查找上次修改的文件夹。(实际上,我只对该文件夹感兴趣,而不对有序列表感兴趣。)我收到-10010错误。
tell application "Finder"
try
set latestFolder to item 1 of (sort (get name of folders of folder ("/Users/c64/Desktop" as POSIX file)) by creation date) as alias
set folderName to latestFolder's name
end try
end tell
如果您要在Desktop上查找name
上次修改folder
的,则可以这样做:
tell application "Finder"
set latestModifiedFolderName to name of item 1 of (sort every folder by modification date)
end tell
顺便说一句,在AppleScript字典用于查找不含条款POSIX file
或POSIX path
使用例如,当POSIX file
一个内部的tell application "Finder"
块,查找将抛出一个非致命错误,如果它可以被裹挟到alias
,否则就抛出一个致命错误。也就是说,如果你正在处理一个POSIX path
,它可能最好将它传递给搜索作为alias
,我建议你强迫的POSIX path
到alias
它传递到前搜索,例如:
set thisFolderPath to POSIX file "/Path/To/Some/Folder" as alias
tell application "Finder"
set latestModifiedFolderName to name of item 1 of (sort every folder of thisFolderPath by modification date)
end tell
注意:该示例 的AppleScript 代码以上,只是,并且不包括任何错误处理作为可适当/需要和/希望,有责任在用户添加任何错误处理对于任何示例代码呈现和或代码以自己写入。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句