我有一个我们办公室用来安排日程的电子表格。每个选项卡代表一个月。我可以将每个选项卡导出到名为month1.csv、month2.csv...等的文件中。我有以下代码可以打开每个月的文件并循环遍历它:
repeat with b from 1 to 12
tell application "Finder"
set curFileName to (sourceFolder & "month" & b & ".csv") as string
--display dialog curFileName
set workingFile to read file (curFileName)
--display dialog "File has been read"
set AppleScript's text item delimiters to {ASCII character 13}
set theContents to text items of workingFile as list
end tell
do stuff with the csv...
end repeat
该脚本遍历第一个月,然后当 b = 2 时出现此错误:
Finder got an error: File file Macintosh HD:Users:lorenjz:Documents:Manpower:,month,2,.csv wasn’t found.
我需要做什么来消除这个错误?