File 在AppleScript中复制文件

File 在AppleScript中复制文件,file,copy,applescript,directory,move,File,Copy,Applescript,Directory,Move,我有下面的代码,可以在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 {"Confi

我有下面的代码,可以在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)
然后我有了调用变量username来复制文件的代码

tell application "Finder"
                copy file theCopy to username
            end tell
但是桌面上的文件theCopy(theCopy是一个变量)不会移动到该文件夹

请帮助。

我建议您使用返回
别名的

要将某些文本转换为alias对象,请使用
将myAliasPath设置为myTextPath as alias

有关更多详细信息,请参阅AppleScript文档。

我建议您使用返回
别名的

要将某些文本转换为alias对象,请使用
将myAliasPath设置为myTextPath as alias


有关更多详细信息,请参阅AppleScript文档。

我相信您误解了
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

我相信您误解了
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