modified on 2 November 2013 at 13:15 ••• 3,699 views


From Predictive Chemistry

Jump to: navigation, search

One-time setup:

sudo aptitude install libusb1-dev golang-go mtp-tools fuse-utils libfuse2
sudo mtp-detect # (will tell you specific vendor and product id)
# These id-s (18d1 and 4ee1) are specific for the Nexus 4:
sudo echo 'ATTRS{idVendor}=="18d1",ATTRS{idProduct}=="4ee1",MODE="0666",GROUP="plugdev"' >/etc/udev/rules.d/50-android.rules
# - add yourself to 'fuse' group (fuse line in /etc/group)
# - log back in to take effect
mkdir $HOME/golang
export GOPATH=$HOME/golang
go get
ln -s $GOPATH/bin/go-mtpfs $HOME/bin

Since the picture filenames all contain the date (e.g. IMG_20130401_000007.jpg), you can use cut to sort them by month.

# mtp-detect
# go-mtpfs droid
# cd droid/Internal\ storage/DCIM/Camera
for i in *; do
  d=`cut -d _ -f 2 <<<"$i"`
  y=`cut -b 1-4 <<< $d`
  m=`cut -b 5-6 <<< $d`
  mkdir -p ~/Pictures/$y/$m
  cp "$i" ~/Pictures/$y/$m
  echo "$i"
# cd
# fusermount -u droid

Otherwise, sorting by file date would have required

find . -newermt "01/01/2013" -and -not -newermt "02/01/2013"

(which lists the file in the month you're looking for).