在 AppleScript 中复制文件 [英] Copy A File In AppleScript
问题描述
我有以下代码在 Applescript 中为 iTunes 音乐文件夹的路径设置一个变量:
I have the code below to set a variable in Applescript for the path to the iTunes Music Folder:
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)
然后我有代码来调用变量用户名来复制文件
And then I have the code to call the variable username to copy a file
tell application "Finder"
copy file theCopy to username
end tell
但是桌面上的文件 theCopy(theCopy 是一个变量)没有移动到文件夹中.
but the file theCopy which is on the desktop (theCopy is a variable) does not move to the folder.
请帮忙.
推荐答案
我相信您误解了 copy
命令.copy
命令用于将一个变量的内容转移到另一个变量中.您需要使用的是duplicate
命令,该命令用于将文件 复制到指定位置.其语法如下:
I believe you've misunderstood the copy
command. The copy
command is used for transferring the contents of one variable into another variable. What you need to use is the duplicate
command, which is used for copying files to a specified location. Its syntax is as follows:
duplicate [alias] to [alias]
[replacing boolean] --If true, replaces files in the destination with the same name
话虽如此,结合 Uriah Carpenter 的回答,您的新代码应该如下所示:
Having said that, your new code, in conjunction with Uriah Carpenter's answer, should look something like this:
set myRingtoneFolder to choose folder with prompt "Select your iTunes Ringtone folder:"
tell application "Finder" to duplicate theCopy to myRingtoneFolder
这篇关于在 AppleScript 中复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!