【问题标题】:Copy A File In AppleScript在 AppleScript 中复制文件
【发布时间】:2011-02-27 17:07:36
【问题描述】:

我有下面的代码在 Applescript 中为 iTunes 音乐文件夹的路径设置一个变量:

set username to text returned of (display dialog "RingtoneDude" default answer "Enter your path to your iTunes Ringtones folder here. e.g. /Users/David/Music/iTunes/iTunes Music/Ringtones" buttons {"Confirm", "Cancel"} default button 1)

然后我有代码来调用变量用户名来复制文件

tell application "Finder"
                copy file theCopy to username
            end tell

但是桌面上的文件 theCopy(theCopy 是一个变量)没有移动到文件夹中。

请帮忙。

【问题讨论】:

    标签: file copy applescript directory move


    【解决方案1】:

    我相信你误解了copy 命令。 copy 命令用于将一个变量的内容传输到另一个变量。您需要使用的是duplicate 命令,用于将文件复制到指定位置。它的语法如下:

    duplicate [alias] to [alias]
       [replacing boolean] --If true, replaces files in the destination with the same name
    

    话虽如此,您的新代码连同 Uriah Carpenter 的回答应该如下所示:

    set myRingtoneFolder to choose folder with prompt "Select your iTunes Ringtone folder:"
    tell application "Finder" to duplicate theCopy to myRingtoneFolder
    

    【讨论】:

      【解决方案2】:

      我建议你使用choose folder,它返回一个alias

      要将一些文本变成别名对象,请使用set myAliasPath to myTextPath as alias

      有关更多详细信息,请参阅 AppleScript 文档中的 Aliases and Files

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-06-12
        • 2010-10-28
        • 2018-08-16
        • 2014-07-06
        • 2018-05-17
        • 1970-01-01
        • 2012-09-26
        相关资源
        最近更新 更多