我正在尝试将多个Excel文件保存到.csv文件中。另外,我想将每个excel文件的名称作为单元格放在每个文件中。问题是我的文件名是韩文,当我把名字放在一个文件中时,字母就会被破坏。我想出的一个可能的解决方案是将韩文文件名转换为unicode,但无法弄清楚如何。以下是我使用的代码。谢谢。
set theFolder to choose folder with prompt "Choose the folder that contains your Excel files"
tell application "Finder" to set theFiles to (files of theFolder)
set fileCount to count theFiles
repeat with i from 1 to fileCount
set fName to text 1 thru -5 of ((name of item i of theFiles) as text)
if ((name of item i of theFiles) as text) ends with ".xls" then
set tName to (theFolder as text) & fName & ".csv"
tell application "Microsoft Excel"
activate
open (item i of theFiles) as text
insert into range column 1 of active sheet
set lastcell to last cell of used range of active sheet
set value of range ("A1:A" & first row index of lastcell) of active sheet to fName
save fName in tName as CSV file format
close active workbook without saving
end tell
end if
end repeat