6 # where we will look for mtp devices.
7 mtp_base_path="/run/user/$UID/gvfs/mtp\:host\="
9 if [ -z "$sourcedir" -o -z "$targetdir" ]; then
10 echo "This script needs source and target directory names that can be synched"
11 echo "between the computer's file system and a USB drive mounted with the mtp"
12 echo "protocol. The folder on the USB drive should include the entire path except"
13 echo "for the device mount location. For example:"
14 echo " $(basename $0) ebooks \"/Internal\ Storage/My\ Files/ebooks\""
18 # the mtp part will flux. if there is more than one device mounted, this will hose up.
19 #checking for more than one device there:
20 mtpdevices=("$mtp_base_path"*)
21 if [ ${#mtpdevices[@]} -ne 1 ]; then
22 echo "There is more than one MTP device mounted. This script requires exactly one"
23 echo "MTP device mounted at a time. Sorry."
25 elif [ ! -d "${#mtpdevices[@]}" ]; then
26 echo "The MTP device does not seem to be mounted currently. The path did not"
27 echo "expand properly."
31 rsync -rv --exclude *.git --exclude *.svn "$sourcedir" "${mtpdevices[0]}/$targetdir"