IRiver T10/T20/T30 MTP - Uploading multiple files (quick&dirty)

View: New views
1 Messages — Rating Filter:   Alert me  

IRiver T10/T20/T30 MTP - Uploading multiple files (quick&dirty)

by NosyMan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 <nosyman@...>
#

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}


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Ifp-driver-common mailing list
Ifp-driver-common@...
https://lists.sourceforge.net/lists/listinfo/ifp-driver-common