我需要修改当前代码,以允许选择文件夹。我当前的代码如下,可以选择一个没有问题的文件夹:
tell application "Finder"
set sourceFolder to folder POSIX file "/Users/Username/Desktop/Upload/Temp/HighRes/"
set theFiles to files of sourceFolder
set inputPath to "/Users/Username/Desktop/Upload/Temp/"
end tell
我尝试了以下操作,但是无法确定正确的语法以获取原始代码中的位置
tell application "Finder"
set inputPath to folder POSIX file (choose folder with prompt "Please choose folder to be processed")
set sourceFolder to folder POSIX file (inputPath & "/HighRes")
set theFiles to files of sourceFolder
end tell
以上处理但出错,并指出发现程序出错,无法将别名“ xyz”设置为整数类型。
答案 0 :(得分:1)
请忘记POSIX舞蹈。 Finder喜欢它的本机和alias
说明符。
tell application "Finder"
-- inputPath is an alias specifier
set inputPath to (choose folder with prompt "Please choose folder to be processed")
-- sourceFolder is built as a Finder item specifier
set sourceFolder to folder "HighRes" of inputPath
set theFiles to files of sourceFolder
end tell
即使您的第一个摘录也可以用更简单的方式编写
tell application "Finder"
set sourceFolder to folder "Upload:Temp:HighRes" of desktop
set theFiles to files of sourceFolder
set inputPath to folder "Upload:Temp" of desktop
end tell