使用applescript删除选定文件夹中的所有文件

时间:2016-01-29 16:01:57

标签: applescript

我目前有一个脚本可以删除14天前特定文件路径中的所有文件:

tell application "Finder"

    delete (every file of folder "client" of folder "test" of folder "Dev, Con & Product" of folder "Google Drive" of folder (path to home folder) whose creation date is less than ((get current date) - 14 * days))

end tell

我正在努力调整这个脚本,以便不要查看" client"文件夹和删除所有文件,它在"客户端1","客户端2","客户端3"文件夹等,并删除所有14天的文件。

对此的任何帮助都会很棒, 感谢

1 个答案:

答案 0 :(得分:0)

假设客户端1,客户端2,...文件夹仍在相同路径中(在文件夹“Dev,Con& Product”中,则保留当前脚本,只需将“客户端”更改为“客户端1” 如果您有许多客户端文件夹,则必须使用重复循环:

set myParent to (((path to home folder) as string) & "Google Drive:Dev, Con & Product:test") as alias
tell application "Finder"
set Myfolders to every folder of folder myParent whose name contains "Client"
repeat with OneFolder in Myfolders
    delete (every file of OneFolder whose creation date is less than ((get current date) - 14 * days))
end repeat
end tell
相关问题