How to organize photos from Camera folder in to folders sorted by month names? 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.
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:

#!/system/bin/sh
set -e

DIR='/sdcard/DCIM/100ANDRO'

find $DIR -maxdepth 1 -type f -iname '*.jp*g' -o -iname '*.png' |
while read -r photo
do
    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" &gt;&amp;2; continue; }

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

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
/sdcard/DCIM/100ANDRO/00100sPORTRAIT_00100_BURST20190222182032908_COVER.jpg
/sdcard/DCIM/100ANDRO/IMG_20170312_013609.jpg
/sdcard/DCIM/100ANDRO/IMG_20180818_180827_HDR.jpg
/sdcard/DCIM/100ANDRO/IMG_20190222_164812.jpg
/sdcard/DCIM/100ANDRO/PANO_20190421_132245.jpg

~$ sort.sh
Done.

~$ find /sdcard/DCIM/100ANDRO/ -type f
/sdcard/DCIM/100ANDRO/2017_03/IMG_20170312_013609.jpg
/sdcard/DCIM/100ANDRO/2018_08/IMG_20180818_180827_HDR.jpg
/sdcard/DCIM/100ANDRO/2019_04/PANO_20190421_132245.jpg
/sdcard/DCIM/100ANDRO/2019_02/00100sPORTRAIT_00100_BURST20190222182032908_COVER.jpg
/sdcard/DCIM/100ANDRO/2019_02/IMG_20190222_164812.jpg


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.