Skip to content

Instantly share code, notes, and snippets.

@nicobo
Created July 16, 2017 11:47
Show Gist options
  • Save nicobo/4a62be0435bbbda0798809003dad2d21 to your computer and use it in GitHub Desktop.
Save nicobo/4a62be0435bbbda0798809003dad2d21 to your computer and use it in GitHub Desktop.
Transfers a batch of files from Bluetooth device to the local computer
#!/bin/sh
#######################
## Transfers a batch of files from Bluetooth device to the local computer.
## Requires obexftp and perl's xpath to be installed.
## This script has been tested on Nokia X3.
#######################
# $srcdir is the directory to transfer to this computer
srcdir="/Carte mémoire/Photos"
# $tmpfile is the XML listing of files
tmpfile=`mktemp`
# allows deleting files from the phone after copying
echo -n "Copy (C) or Move (M) ? " && read erasesrc
case $erasesrc in
m|M) optget="--getdelete";;
*) optget="--get";;
esac
obexftp -b -l "$srcdir" > $tmpfile
xpath -n -q -e "//folder-listing/file/@name" $tmpfile | sed -r 's/name="(.+)"/\1/' | xargs obexftp -b -c "$srcdir" $optget
rm -f $tmpfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment