Last active
April 8, 2021 07:02
-
-
Save timlien/f478b891289c64ea2f50dc37716aebae to your computer and use it in GitHub Desktop.
Export mac numbers file into csv format with apple script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/osascript | |
on run argv | |
set theFilePath to POSIX file (item 1 of argv) | |
set theFolder to theFilePath as alias | |
tell application "System Events" to set theDocs to theFolder's items whose name extension = "numbers" | |
repeat with aDoc in theDocs | |
set docName to aDoc's name as text | |
set exportName to (theFolder as text) & docName | |
set exportName to exportName's text 1 thru -8 | |
-- set exportName to (exportName & "csv") -- append .csv to directory name | |
tell application "Numbers" | |
launch | |
open aDoc | |
delay 3 -- may need to adjust this higher | |
export front document to file exportName as CSV | |
end tell | |
end repeat | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That worked pretty fine, thanks. Only there's no extension in the exported file, so you may want to add a
set exportName to (exportName & "csv")
just between lines 17 and 18.