在 AppleScript 中复制文件

Wil*_*ans 1 directory applescript copy file 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 {"Confirm", "Cancel"} default button 1)
Run Code Online (Sandbox Code Playgroud)

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

tell application "Finder"
                copy file theCopy to username
            end tell
Run Code Online (Sandbox Code Playgroud)

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

请帮忙。

fir*_*w52 5

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

duplicate [alias] to [alias]
   [replacing boolean] --If true, replaces files in the destination with the same name
Run Code Online (Sandbox Code Playgroud)

话虽如此,您的新代码与 Uriah Carpenter 的回答相结合,应该如下所示:

set myRingtoneFolder to choose folder with prompt "Select your iTunes Ringtone folder:"
tell application "Finder" to duplicate theCopy to myRingtoneFolder
Run Code Online (Sandbox Code Playgroud)