Comment on this news article
applescript - I want to convert a Spreadsheet to a .txt file on Mac …
Comment on this news article
applescript - I want to convert a Spreadsheet to a .txt file on Mac …
I am surprised they did not let him to rephrase the question…
set theFolder to choose folder
set pPath to POSIX path of theFolder
set csvNames to every paragraph of (do shell script "ls " & pPath)
tell application "Finder" to set csvFiles to every file of folder theFolder
repeat with i from 1 to count of csvNames
tell application "Finder"
set {filePath, theFile} to {(item i of csvFiles as string), (item i of csvFiles as alias)}
tell (info for theFile) to set {fileName, nameExtension} to {name, name extension}
set baseName to text 1 thru ((get offset of "." & nameExtension in fileName) - 1) of fileName
set savePath to theFolder & baseName & ".csv" as string
end tell
tell application "Microsoft Excel"
open file filePath
delay 3
set bookName to name of active workbook
tell workbook bookName
save workbook as filename savePath file format CSV file format
delay 1
end tell
set bookName to name of active workbook
close workbook bookName without saving
end tell
end repeat