在 AppleScript 中复制文件
我有下面的代码在 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 是一个变量)不移动到该文件夹。
请帮忙。
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
but the file theCopy which is on the desktop (theCopy is a variable) does not move to the folder.
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信您误解了
copy
命令。copy
命令用于将一个变量的内容传输到另一个变量。您需要使用的是duplicate
命令,该命令用于将文件复制到指定位置。它的语法如下:话虽如此,您的新代码与 Uriah Carpenter 的答案相结合,应该如下所示:
I believe you've misunderstood the
copy
command. Thecopy
command is used for transferring the contents of one variable into another variable. What you need to use is theduplicate
command, which is used for copying files to a specified location. Its syntax is as follows:Having said that, your new code, in conjunction with Uriah Carpenter's answer, should look something like this:
我建议您使用
选择文件夹< /code>
返回一个
别名
。要将某些文本设置为别名对象,请使用
将 myAliasPath 设置为 myTextPath 作为别名
。有关更多详细信息,请参阅别名和文件。
I would suggest you use
choose folder
which returns analias
.To make some text into an alias object use
set myAliasPath to myTextPath as alias
.For more detailed information see Aliases and Files in the AppleScript documentation.