#!/bin/sh app=0 script=" property plname : \"ZZZ_cmdplayline\" tell application \"iTunes\" activate" case $1 in -append) app=1 shift ;; -replay) script="$script\nplay user playlist plname\nreveal user playlist plname\nend tell" echo "$script" | /usr/bin/osascript exit ;; esac if [ $# = 0 ] then echo Tell me the full path name of the files to play exit fi script="$script if not (exists playlist plname) then make new user playlist with properties {name:plname} end if" if [ $app = 0 ] then script="$script delete every track of user playlist plname" fi for a do if [ ! -f "$a" ] then echo Can not find file: $a exit fi case $a in /*) # OK ;; *) a=$PWD/$a ;; esac script="$script add posix file \"$a\" to user playlist plname" done if [ $app = 0 ] then script="$script play user playlist plname tell current playlist to set song repeat to all" else script="$script play" fi script="$script reveal user playlist plname end tell" echo "$script" | /usr/bin/osascript