3

我正在尝试将多个 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
4

0 回答 0