
이 게시물을 기반으로파일을 재생하지 않고 명령줄에서 iTunes에 파일을 추가하는 방법하나가 아닌 여러 파일을 추가하고 싶습니다.
루프와 찾기를 추가해 보았습니다.
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
버전(끝부분에 "완료" 없음) 의 경우 {}
다음과 같이 인용하세요.
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