【发布时间】:2014-03-19 23:17:56
【问题描述】:
我有以下 AppleScript:
to copyMovieTemplate(sermonCode)
local iMovieProject
set iMovieProject to ((iMovieSermonsPath as text) & sermonCode & ".rcproject")
display dialog ("Copying " & (sermonTemplate) & " to " & (iMovieProject as text))
tell application "Finder"
duplicate file sermonTemplate to file iMovieProject without replacing
end tell
end copyMovieTemplate
sermonTemplate 和 iMovieSermonsPath 变量是 aliases:
global sermonTemplate
global iMovieSermonsPath
set sermonTemplate to alias ((iMovieSermonsPath as text) & "Sunday Service Template.rcproject")
set iMovieSermonsPath to alias ((iMovieProjects as text) & "Sermons:")
当我运行此脚本时,我收到一条错误消息,告诉我 Finder 无法将目标文件复制到目标文件:
Finder 出现错误:无法将文件“Macintosh HD:Users:vitabile:Movies:iMovie Projects.localized:Sermons:14-0101-01.rcproject”设置为文件“Macintosh HD:Users:vitabile:Movies: iMovie Projects.localized:Sermons:14-0101-01.rcproject"。
我做错了什么?做这个副本的正确方法是什么?
编辑 1
我什至尝试删除 without replacing 子句,但没有任何区别。
编辑 2
经过一番搜索,我找到了this post,加上评论中的反馈,所以我重写了我的代码:
-- Copy the Sunday Sermon Template file to the iMove Projects folder
to copyMovieTemplate(sermonCode)
-- Convert the sermonCode into a file name for the iMovie project
set iMovieProject to sermonCode & ".rcproject"
display dialog ("Copying " & (sermonTemplate as text) & " to " & iMovieProject as text)
tell application "Finder"
try
set theCopy to duplicate alias sermonTemplate to folder alias iMovieSermonsPath
set name of theCopy to iMovieProject
on error errStr
display dialog ("Unable to copy the Sunday Sermon Template project to " & (iMovieSermonsPath as text) & iMovieProject & ".")
display dialog "Error: " & errStr
error number -128
end try
end tell
end copyMovieTemplate
这仍然不起作用,但错误已更改:
Finder 出错:无法将别名“Macintosh HD:Users:vitabile:Movies:iMovie Projects.localized:Sermons:”转换为整数类型。
使用系统事件不起作用,因为我遇到了同样的错误。
【问题讨论】:
-
查看我对 OP 的第二次编辑。
标签: applescript