如何重命名applescript中的文件夹而不获取-10006错误

如何重命名applescript中的文件夹而不获取-10006错误,applescript,directory,rename,automator,Applescript,Directory,Rename,Automator,在自动程序脚本要求用户选择一个文件夹之后,我有了这个applescript- on run {input, parameters} try set theFolder to input tell application "Finder" to set name of theFolder to "test" on error e number n set theLine to (do shell script "date +'%Y-%m-%d %H:%M:%S'" as

在自动程序脚本要求用户选择一个文件夹之后,我有了这个applescript-

on run {input, parameters}
try
    set theFolder to input
    tell application "Finder" to set name of theFolder to "test"

on error e number n
    set theLine to (do shell script "date  +'%Y-%m-%d %H:%M:%S'" as string) & " " & "OOPs: " & e & " " & n
    do shell script "echo " & theLine & " >> ~/Library/Logs/AudioModdeer-events.log"
end try

return input
end run
我的日志显示以下错误-

2013-09-03 16:50:56 OOPs:AppleeEvent处理程序失败-一万


2013-09-03 16:51:28 OOPs:无法将{alias Macintosh HD:Users:Audio:Music:Ableton:User Library:Samples:Samples:}的名称设置为测试-10006

您必须从输入列表中引用一项

set theFolder to first item of input

我对AppleScript几乎是个新手,但我今天发现以下几点也行:

移动的内容以在别名处创建属性为{name::}的新文件夹


希望这对你也有用。

这个答案是正确的。我只想指出错误消息说明了问题所在。注意文件路径周围的“{}”括号表示它是一个列表。因此,按照adayzdone的建议获取输入的第1项。啊,谢谢你们指出这一点,也谢谢你们两位教男人如何钓鱼!