For various reasons, I often end up pulling photos of my phones by connecting the USB connection to a computer and extracting what I need.

The problem I am facing is that my DCIM/100ANDRO folder is now huge, and simply loading the full list of files takes considerable time. Is there some way (ideally in basic Android 7.1.1, but additional apps are acceptable) to sort these in to separate folders possibly by month of taking or similar. Onus points if this happens dynamically as photos are taken.

I'd also be interested in alternatives to the USB -> browse device options, but I'd want something that does full resolution, doesn't upload to an internet location first, and doesn't require bluetooth.

  • Android 7 stock Photo Gallery has some basic views by default, you can group by time or by location. Is this sufficient for your needs, or do you mandatory need to sort in folders?
    – alecxs
    Jul 26, 2019 at 14:40
  • @alecxs folder's I'm afraid - the problem isn't navigating on the device itself, it's when I browse the SD card from an attached device. If there's a quick way to "send" full res photos to a nearby PC, ideally via the USB as the network situation is complicated, that would work too.
    – CMaster
    Jul 26, 2019 at 15:03
  • Do you mean when connected via USB MTP, it takes too long to show, so you never be able to start copying DCIM folder, because you can't see/select folder for copying?
    – alecxs
    Jul 27, 2019 at 5:59
  • You could run a shell script each time on triggering event (for example on gallery start) which creates subfolders and move files into with MacroDroid
    – alecxs
    Jul 30, 2019 at 10:43
  • for a simply transfer you could enable USB debugging in developer settings and run from cmd.exe when connected via USB cable (or adb over wifi) adb.exe pull -a -p /sdcard/DCIM/Camera
    – alecxs
    Jul 30, 2019 at 10:56

1 Answer 1


There must be apps to facilitate what you want to achieve, but one of very straight forward method (for me at least) is to use a shell script as suggested by @alecxs in comment. We can read date of Photo Taken using exiv2 commandline tool. You can build from source or try this one. Or get Modified Time of photo using stat command, but the former is usually more accurate because some programs like file explorers badly change the modified date e.g. during copy/move operation.

Once the month of photo is known, create respective folder and move photo there:

set -e


find $DIR -maxdepth 1 -type f -iname '*.jp*g' -o -iname '*.png' |
while read -r photo
    month=$(exiv2 -q pr "$photo" | busybox awk -v c=1 -F '[: ]' '/timestamp.*[0-9]{4}:[0-9]{2}:[0-9]{2}/{print $5"_"$6; c=0} END{exit c}') ||
    month=$(busybox stat -c %y "$photo" | busybox awk -v c=1 -F '[- ]' '/[0-9]{4}-[0-9]{2}-[0-9]{2}/{print $1"_"$2; c=0} END{exit c}') ||
    { echo "Couldn't find month for $photo" >&2; continue; }

    mkdir -p "$DIR/$month"
    mv -n "$photo" "$DIR/$month/"

echo Done.

Android's awk and stat are buggy or show non-standard behavior. Better use busybox.

Let's name the script sort.sh. This is how it works:

~$ find /sdcard/DCIM/100ANDRO/ -type f

~$ sort.sh

~$ find /sdcard/DCIM/100ANDRO/ -type f

Additionally you may use file command (instead of relying on file extensions) to only move photos and not videos or other files. But again Android's /system/bin/file is very limited. Either use one from Termux, or build from source, or try this one.

You can run this script manually or on a regular basis using some automation app. crond is also an option if you have root.

I'd also be interested in alternatives to the USB -> browse device options

This part is itself a separate question. If you want to browse files from PC you can go for adbfs, SSHFS/SFTP, FTP, WebDAV, SMB etc. Or to simply transfer files adb pull will suffice and is reasonably faster. If you have root and the volume of data to be transferred is high, consider using USB Mass Storage (UMS) from custom recovery. It's very high speed and reliable method.

  • Can this be run without root? (I'll have to search on how to pull up shell etc, but sure I can figure that out)
    – CMaster
    Aug 11, 2019 at 16:31
  • 1
    No root required. You can run script from adb shell or terminal emulator app like Termux. Aug 11, 2019 at 18:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .