应用程序Finder一起删除文件夹

时间:2014-06-12 21:00:09

标签: applescript

以下是我的代码:

 set sourceFolder1 to (path to library folder as text) & "Frameworks:SDL_mixer.framework"

set sourceFolder2 to (path to library folder as text) & "Frameworks:SDL_ttf.framework"

set sourceFolder3 to (path to library folder as text) & "Frameworks:SDL_image.framework"



set folderList to {sourceFolder1, sourceFolder2}

tell application "Finder"

repeat with thisFolder in folderList

    if exists folder thisFolder then

        delete folder thisFolder
    end if

end repeat


end tell

此代码的问题是:我必须为每个要删除的框架(到垃圾文件夹)提供密码,是否有办法只为所有删除工作提供一次密码?

我不能将shell脚本与rm一起使用(因为rm会将文件移动到垃圾文件夹,但没有放回选项)。

我注意到删除框架后,它会删除1项。但是当我使用Finder删除多个文件时,它会删除N个项目。如何实现相同的功能,而不是每次在我的代码中删除1项,一次删除N项,当然也只提供一次密码。非常感谢。

LJ

2 个答案:

答案 0 :(得分:1)

试试这个:

tell application "Finder" to delete {sourceFolder1, sourceFolder2, sourceFolder3}

答案 1 :(得分:0)

首先,感谢所有回复。

它基于user309603给出的代码,进行了一些修改。

set sourceFolder1 to (path to library folder as text) & "Frameworks:SDL_mixer.framework"

set sourceFolder2 to (path to library folder as text) & "Frameworks:SDL_ttf.framework"

set sourceFolder3 to (path to library folder as text) & "Frameworks:SDLimage.framework"


set list1 to {}


tell application "Finder"
activate

if exists folder sourceFolder1 then
    set list1 to {sourceFolder1}
end if

if exists folder sourceFolder2 then
    set list1 to list1 & sourceFolder2
end if

if exists folder sourceFolder3 then
    set list1 to list1 & sourceFolder3
end if


delete list1    

end tell

再次感谢您的帮助!