commit 99fbefdd354ab50b3cc5aa0d75b9a322dea6090d Author: James Eagan Date: Mon Sep 18 16:44:26 2023 +0200 Initial commit diff --git a/numbers2csv.fish b/numbers2csv.fish new file mode 100644 index 0000000..2d34954 --- /dev/null +++ b/numbers2csv.fish @@ -0,0 +1,39 @@ + +function numbers2csv + set argn (count $argv) + if test $argn -gt 2 -o $argn -eq 0 + echo "*** Usage: numbers2csv []" + 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