复制一个文件的AppleScript [英] Copy A File In AppleScript

查看:488
本文介绍了复制一个文件的AppleScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下code设置一个变量的AppleScript的路径到iTunes Music文件夹:

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)

然后我有code调用变量名复制文件

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.

请帮忙。

推荐答案

我相信你误解了复制命令。在复制命令用于一个变量的内容转移到另一个变量。你需要使用什么是复制命令,这是用于复制的文件以指定位置。它的语法如下:

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

说了这么多,你的新的code,与乌利亚木匠的答案相结合,应该是这个样子:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆