OSX + bash + AppleScript + iTunes error
Posted: October 5th, 2009, 1:52 pm
I am having trouble getting my bash script to work.
Basically the script converts all the avi files in the directory to mp4 and then tries to add it to iTunes.
Everything works fine until I try to add the file to iTunes. I get the error:
Here is the code:
Anyone have any ideas?
Basically the script converts all the avi files in the directory to mp4 and then tries to add it to iTunes.
Everything works fine until I try to add the file to iTunes. I get the error:
Code: Select all
168:202: execution error: iTunes got an error: Can’t make some data into the expected type. (-1700)Code: Select all
#!/bin/bash
# 1 The final directory of the job (full path)
# 2 The name of the NZB file
# 3 Clean version of the job name (no path info and ".nzb" removed)
# 4 Newzbin report number (may be empty
# 5 Newzbin or user-defined category
# 6 Group that the NZB was posted in e.g. alt.binaries.x
DIR=$1
NZB_FILE=$2
NAME=$3
NZB_ID=$4
CATEGORY=$5
GROUP=$6
echo "Directory: "$DIR
echo "NZB Filename: "$NZB_FILE
echo "Job Name: "$NAME
echo "NZB ID: "$NZB_ID
echo "Category: "$CATEGORY
echo "Usenet Group: "$GROUP
echo ""
echo ""
shopt -s nullglob
cd "$DIR"
for i in *.avi; do
HandBrakeCLI -i "$i" -o "${i%.*}"".mp4" --preset="iPhone & iPod Touch"
if [[ $? -ne 0 ]]; then
exit 1
fi
exec osascript <<APPLESCRIPT
tell application "iTunes"
set posix_path to "$DIR${i%.*}.mp4"
-- return posix_file
-- i tested and posix_file is set to the correct file name
set mac_path to posix_path as POSIX file
-- return mac_path
-- i tested and mac_path is set to the correct file name
add mac_path to library playlist 1
end tell
APPLESCRIPT
done
exit 0