HowTo:AndroidPhoto

From Predictive Chemistry
Jump to: navigation, search

One-time setup: <source lang="bash"> sudo aptitude install libusb1-dev golang-go mtp-tools fuse-utils libfuse2 sudo mtp-detect # (will tell you specific vendor and product id)

  1. 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

  1. - add yourself to 'fuse' group (fuse line in /etc/group)
  2. - log back in to take effect

mkdir $HOME/golang export GOPATH=$HOME/golang go get github.com/hanwen/go-mtpfs

ln -s $GOPATH/bin/go-mtpfs $HOME/bin </source>

Since the picture filenames all contain the date (e.g. IMG_20130401_000007.jpg), you can use cut to sort them by month. <source lang="bash">

  1. mtp-detect
  2. go-mtpfs droid
  3. 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"

done

  1. cd
  2. fusermount -u droid

</source>

Otherwise, sorting by file date would have required <source lang="bash"> find . -newermt "01/01/2013" -and -not -newermt "02/01/2013" </source> (which lists the file in the month you're looking for).