用applescript复制文件夹

时间:2012-05-21 19:32:18

标签: applescript

因此我被指示为我的工作编写脚本,我们的目标是能够在计算机上选择文件夹并将它们备份到我们其中一台服务器上的文件夹中。到目前为止,我给出了安装服务器的脚本,将用户用户名作为输入,并在服务器上创建一个名为该用户名的文件夹。下一步是将选定的文件夹复制到服务器上的新文件夹中,这就是我遇到速度障碍的地方(我有一行代码可以让用户选择多个文件夹,我只是无法让它们到达复制到该新文件夹)

这是我到目前为止的代码。

display dialog "Please enter your augnet username" default answer "username"
set username to (text returned of result)

mount volume "smb://orgs.augsburg.edu"

delay 3

tell application "Finder"
    set folder backup to make new folder at folder "ORGS:Information Technology:www:kb_images:Migration Testing:" with properties {name:username}
end tell

choose folder with prompt "Please select what you would like to transfer" with multiple selections allowed
set theSelection to result

tell application "Finder" to duplicate theSelection to folder backup

2 个答案:

答案 0 :(得分:0)

你可以使用这样的shell脚本:

do shell script "cd " & theDestination & "; cp " & theSelection

这只是一个例子,需要应用于您的案例,尤其是“目标”部分。基本上它使用shell脚本将目录更改为您的destionation然后复制选择。请注意,您可能需要选择副本(对于文件夹和文件替换等)。

你可以通过applescript实现你所做的一切shell,也许没有定义文件夹备份,因为它不存在?

答案 1 :(得分:0)

尝试:

tell application "Finder"
set backup to make new folder at folder "ORGS:Information Technology:www:kb_images:Migration Testing:" with properties {name:username}
    set theSelection to choose folder with prompt "Please select what you would like to transfer" with multiple selections allowed
    duplicate folder theSelection to backup
end tell