据我所知,更改文件名的标准AppleScript代码是:
set name of my_file to "New_Name"
但是当我在重复循环中使用它(由文件夹操作调用)时,我收到“堆栈溢出”错误。这是完整的代码:
on adding folder items to this_folder after receiving these_items
try
repeat with this_item in these_items
set name of this_item to "New_Name"
end repeat
on error error_message number error_number
display dialog error_message buttons {"Cancel"} default button 1
end try
end adding folder items to
有没有人遇到过这个问题?可能与Mountain Lion有什么关系?
答案 0 :(得分:1)
尝试:
tell application "System Events" to set name of this_item to "New_Name"