How can I change my pictures' and videos' date on my phone by their filenames?
I ended up writing a rather dirty script to do this. For this to work, I'm assuming you have a rooted device, and the directory that contains the pictures and videos is /sdcard/DCIM/Camera. If otherwise, change the script.


Download BusyBox and install it. This is needed for executing Linux shell commands.
Create a script called script.sh, containing this block of code, and put it on the root of your sd card.

cd DCIM/Camera
echo "Navigated to `pwd`"

ls

for f in *.jpg *.3gp *.m4v
do

  [ -e $f ] || continue    ## testing if the file exists
  NEWDATE=`echo $f | sed 's|IMG_||g' | sed 's|VID_||g' | sed 's|_||g' | \
  sed 's|.3gp||g'  | sed 's|.m4v||g' | sed 's|.jpg||g' | sed 's|........|&amp;\.|g'`

  echo "Touching date $NEWDATE into $f..."

  touch -t "$NEWDATE" "$f" ## using touch to insert the new date into the file

done

Start adb shell, and execute:

su
mount -o remount rw /sdcard


to make sure you can actually edit the files
Move to your sd card:

cd /sdcard

Execute the shell script:

sh script.sh

Now start the Gallery app, and wait. Especially if you have a large file collection, it may take Android a while to sort everything and update the cache.