From: NosyMan <no...@gm...> - 2005-12-29 07:26:26
|
Hi folks, Here you have a bash script for uploading files to your iRiver Tx. You also need gphoto2 v2.1.99 and the latest CVS of gphoto2. #!/bin/sh # # Quick and dirty: uploading files to iRiver Tx MTP series flash based players # Author: NosyMan <no...@gm...> # CMD="gphoto2 -f" ROOT="/store_00010001" DEFAULTROOT="MUSIC" echo " ------------------------------------- iRiver Tx series upload utilitie v0.1 ------------------------------------- " case "$#" in "0") echo " Usage $0 SRC_FILE [DST_PREFIX] Usage $0 SRC_DIR [DST_PREFIX] e.g.: ${0} /tmp/mp3s - will upload all files and directories below /tmp/mp3s to default location ${0} /tmp/mp3s /MUSIC/MyMP3 - will upload all files and directories below /tmp/mp3s to /MUSIC/MyMP3 ${0} /tmp/mp3s/test.mp3 /MUSIC/MyMP3 - will upload 'test.mp3' to /MUSIC/MyMP3" exit 1 ;; "2") DEFAULTROOT=$2 ;; esac DEFAULTROOT="${ROOT}/${DEFAULTROOT}" function recScan() { local ROOT=$2 local LIST=`ls -1 $1` for file in $LIST do if [ -f "$1/${file}" ]; then file_upload ${ROOT} $1/${file} else if [ -d "$1/${file}" ]; then dir_upload ${ROOT} ${file} recScan $1/${file} ${ROOT}/${file} fi fi done } function file_upload() { # $1 - dir, $2 - file echo " Uploading: SRC: $2 DST: $1" ${CMD} $1 -u $2 } function dir_upload() { # $1 - dir, $2 - dir echo "Creating directory $1/$2... " ${CMD} $1 -m $2 } echo "iRiver's base dir=${DEFAULTROOT}" recScan $1 ${DEFAULTROOT} |