
この投稿に基づいてファイルを再生せずにコマンドラインからiTunesにファイルを追加するにはどうすればいいですか?1 つのファイルではなく複数のファイルを追加したいのですが、これは機能します。
ループと検索を追加してみました:
for f in ./*.m4a; do osascript -e \
"tell application \"iTunes\" to add "$f" Posix file; done
# Or...
find /Users/filedirectory\
-type f -name "*.m4a" \
-osascript -e "tell application \"iTunes\" to add Posix file {}; done
ターミナルは>
エラーなしで を返します。
答え1
AppleScript では、POSIX パスを引用符で囲む必要があり、iTunes のパスは完全なパス名である必要があります。
シェルfor
コマンドの場合、パスは完全パスである必要があるため、引用符で囲む必要がありますpwd
。$f
for f in "`pwd`"/*.m4a; do osascript -e \
"tell application \"iTunes\" to add Posix file \"$f\""; done
find
バージョン(最後に「done」がない)の場合は、{}
次のように引用します。
find /Users/filedirectory \
-type f -name "*.m4a" \
-exec osascript -e "tell application \"iTunes\" to add Posix file \"{}\"" \;
pwd
現在のディレクトリ内のファイルを検索するには を使用します。 の後のpwd
コマンドの残りは同じです。
find "`pwd`" -type f ...
iTunes に追加された各ファイルには、次のような行が表示されます。
file track id 142123 of library playlist id 25858 of source id 65