#!/bin/sh # # obexftp-get-folder.sh # # Developed by Ondrej Jombik # Copyright (c) 2005 Platon SDG, http://platon.sk/ # Licensed under terms of GNU General Public License. # All rights reserved. # # Changelog: # 2005-02-03 - created # # $Platon: scripts/shell/obex/obexftp-get-folder.sh,v 1.2 2005/02/07 14:15:30 nepto Exp $ if [ "X$1" = "X" ]; then echo "Usage: $0 "; exit 1; fi DIR="`pwd`/$1"; list="` obexftp-list.sh "$1" | sed 's/ /_/g' `"; if [ "X$list" = "X" ]; then echo "ERROR: empty list (not connected?)"; exit 2; fi if [ -e "$DIR" ]; then echo "WARNING: folder exists"; fi echo -n "Creating '$DIR'... "; mkdir -p "$DIR"; if [ $? -ne 0 ]; then echo "FAILED"; exit 8; fi echo "OK"; cd "$DIR" || exit; for i in $list; do file="` echo \"$i\" | sed 's/:.*$//g' `"; ts="` echo \"$i\" | sed 's/^.*://g' `"; tts="` echo \"$ts\" | sed 's/T//g; s/\(..\)$/\.\1/g;' `"; echo "----- $file -----"; if [ -e "$file" ]; then echo "File exists, skipping..."; continue; fi obexftp -b --get "$1/$file" && touch -c -t "$tts" "$file"; if [ $? -ne 0 ]; then echo "ERROR processing file"; sleep 1; continue; fi; echo "OK, processed"; tsf="$ts"; j=2; while [ -e "$tsd" ]; do tsf="$ts-$j"; j=$(( j + 1 )); done cp "$file" "$tsf" && touch -c -t "$tts" "$tsf"; if [ $? -ne 0 ]; then echo "ERROR creating copy"; else echo "OK, copy created"; fi done cd -;