カレントディレクトリのnumbersのファイルを一括して、csvに変換する方法を紹介する。
変換したいファイルのあるディレクトリに移動し、以下のコマンドをターミナルで実行する。
find . -name "*.numbers" -print0 | while IFS= read -r -d '' f; do
# 絶対パスに変換
abs_in="$(cd "$(dirname "$f")"; pwd)/$(basename "$f")"
abs_out="${abs_in%.numbers}.csv"
echo "Converting: $abs_in -> $abs_out"
osascript -e 'on run argv
set inPath to item 1 of argv
set outPath to item 2 of argv
set inAlias to POSIX file inPath as alias
set outFile to POSIX file outPath
tell application "Numbers"
set theDoc to open inAlias
delay 0.5
export theDoc to outFile as CSV
close theDoc saving no
end tell
end run' "$abs_in" "$abs_out"
done