Initial commit
commit
99fbefdd35
|
@ -0,0 +1,39 @@
|
|||
|
||||
function numbers2csv
|
||||
set argn (count $argv)
|
||||
if test $argn -gt 2 -o $argn -eq 0
|
||||
echo "*** Usage: numbers2csv <file> [<output-file>]"
|
||||
return -1
|
||||
end
|
||||
|
||||
set inputPath (path resolve $argv[1])
|
||||
#set exportPath (path change-extension csv $inputPath)
|
||||
|
||||
if test $argn -eq 2
|
||||
set exportPath (path resolve $argv[2])
|
||||
else
|
||||
set exportPath (mktemp)
|
||||
#trap "rm -f $exportPath" 0 2 3 15 #doesn't seem to work
|
||||
end
|
||||
|
||||
set applescript "
|
||||
set inputPath to \"$inputPath\"
|
||||
set exportPath to \"$exportPath\"
|
||||
set inputFile to POSIX file inputPath
|
||||
set exportFile to POSIX file exportPath
|
||||
|
||||
tell application \"Numbers\"
|
||||
set theDocument to open inputFile
|
||||
delay 1
|
||||
export theDocument to exportFile as CSV
|
||||
close theDocument
|
||||
end tell
|
||||
"
|
||||
|
||||
osascript -e $applescript
|
||||
|
||||
if test $argn -eq 1
|
||||
cat $exportPath
|
||||
rm -f $exportPath
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue