Applescript将每个文件/文件夹复制到新创建的文件夹中

时间:2015-10-27 08:24:19

标签: applescript

我有一个Applescript可以自动将文件从一个目录复制到另一个目的地。因为我是Apple Script的新手,我在将文件/文件夹复制到新创建的文件夹时遇到问题。

因为我的脚本是这样的

set dt to (current date) as Unicode text 

tell application "Finder"
  make new folder at alias "Macintosh HD:Users:XYZ:" with properties {name:dt}
  //In above code, new folder create automatically with system date and time on specified location like Tuesday, October 1, 2015 at 12/02/48 PM
  copy folder "Macintosh HD:Users:XYZ:Desktop:ABC:" to folder "Macintosh HD:Users:XYZ:"
  //In above code, I am facing issue that I am not able to copy file into created newly system date and time folder. How can I copy folder into newly created system date and time folder?
end tell

任何人都可以帮助我吗?

提前致谢。

1 个答案:

答案 0 :(得分:1)

首先,复制项目的Finder命令是duplicate

make new folder返回对新文件夹的引用。将此引用用作目标。

set dt to (current date) as Unicode text 

tell application "Finder"
  set newFolder to make new folder at alias "Macintosh HD:Users:XYZ:" with properties {name:dt}
  duplicate folder "Macintosh HD:Users:XYZ:Desktop:ABC:" to newFolder
end tell