【问题标题】:In AppleScript, how do I copy a directory's contents to another directory without deleting the destination directory's existing files?在 AppleScript 中,如何将目录的内容复制到另一个目录而不删除目标目录的现有文件?
【发布时间】:2014-11-18 23:31:10
【问题描述】:

我正在尝试将文件和目录从一个名为“Motion Templates”的目录复制到另一个名为“Motion Templates”的目录。

tell application "Finder"
    set srcPath to ((parent of (path to me) as text) & "Motion Templates")
    set dstPath to (((path to movies folder) as text) & "Motion Templates")
    set srcFolder to folder srcPath
    set dstFolder to folder dstPath

    duplicate entire contents of srcFolder to dstFolder with replacing
end tell

源目录 (Motion Templates) 包含一个子目录 (Generators),它根据匹配的文件路径成功复制到目标“Motion Templates”(从源“Motion Templates/Generators”到目标“Motion Templates/发电机”)。但是,此脚本也会删除“Motion Templates/Generators”中存在的所有现有子目录。如何在不删除树中其他现有文件的情况下复制/覆盖文件?

【问题讨论】:

    标签: file automation applescript


    【解决方案1】:

    当您使用相同的名称时,这很难解释。这就像第一次试图了解谁先上。尝试使用不同的文件夹名称,直到你可以让它工作,然后担心什么叫什么。

    为了尝试帮助我唯一能说的是,如果文件具有相同的确切名称并且您使用“替换”,它将覆盖目标文件夹中的任何内容。如果您说源文件夹正在被删除,那么您遇到了文件被移动而不是复制的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-29
      • 1970-01-01
      • 2011-09-07
      • 1970-01-01
      • 2017-11-18
      • 1970-01-01
      • 2014-07-18
      相关资源
      最近更新 更多