我在网上四处寻找这个答案,所以我很抱歉,如果它在某处。下面的这个脚本工作正常,除了它返回.DS_Store文件的事实我如何从这个查询和所有其他隐藏文件中排除它,但因为我在我的脚本中创建了唯一的文件夹.DS_Store < / p>
告诉应用程序“系统事件” 将listOfInputs设置为文件夹a的每个磁盘项的POSIX路径作为列表 结束告诉
以下是完整的脚本。我在创建文件后将文件放入文件夹中,但最终会在创建之前提示文件。
运行
tell application "Finder"
if not (exists folder "IN") then
make new folder at desktop with properties {name:"IN"}
end if
if not (exists folder "OUT") then
make new folder at desktop with properties {name:"OUT"}
end if
end tell
set theINfolder to path to the desktop as string
set a to theINfolder & "IN:"
tell application "System Events"
set listOfInputs to POSIX path of every disk item of folder a as list
end tell
set inputs to listOfInputs
set theOutfolder to path to the desktop as string
set outputFolder to theOutfolder & "OUT:"
set params to {}
main(inputs, outputFolder, params)
结束
答案 0 :(得分:1)
以下内容可行:
set listOfInputs to list folder a without invisibles
但without invisibles
无法与POSIX path
结合使用,因此我们使用循环代替:
set listOfInputs to {}
tell application "System Events"
set the_items to list folder a without invisibles
repeat with i from 1 to the count of the_items
set this_item to alias ((a as Unicode text) & (item i of the_items))
set end of listOfInputs to POSIX path of this_item
end repeat
end tell
答案 1 :(得分:0)
列表文件夹命令已被弃用,可能会意外停止工作。
尝试:
set inFolder to (path to desktop as text) & "IN"
do shell script "mkdir -p " & quoted form of (POSIX path of inFolder)
set listOfInputs to paragraphs 2 thru -1 of (do shell script ("find " & quoted form of (POSIX path of inFolder) & " \\! -name \".*\""))
您可以将结果作为由空格分隔的字符串获取,如下所示:
set inFolder to (path to desktop as text) & "IN"
do shell script "mkdir -p " & quoted form of (POSIX path of inFolder)
set {TID, text item delimiters} to {text item delimiters, " "}
set listOfInputs to paragraphs 2 thru -1 of (do shell script ("find " & quoted form of (POSIX path of inFolder) & " \\! -name \".*\"")) as text
set text item delimiters to TID