#!/bin/sh # #---makeIphoneVideoNamesSensible # # Shell script for linux, Windows/Cygwin, or MacOS. Last updated 2020-01-12. # # Converts MOV files from iPhones (with stupid names like IMG_0001.MOV) # into files named with the date and time stamp from the video file. # (E.g. 20171003_151026.mov) # # Usage: run it in a directory containing .MOV files downloaded from an # iPhone. Renames all of them. # # Requires installing the 'exiftool'. See https://exiftool.org/install.html # # Copyright (C) 2020 by Charles Roth, 2020-01-12, croth (a t) thedance (d o t) net # Released under the Creative Commons Attribution-only ("BY") license. # (See https://en.wikipedia.org/wiki/Creative_Commons_license#Seven_regularly_used_licenses) #---------------------------------------------------------------------------- tmp=/tmp/iphonevideo$$ rm -f $tmp for x in `ls *.MOV *.mov 2>/dev/null`; do exiftool $x | grep "^Create Date" >$tmp 2>/dev/null if test -s $tmp; then newname=`sed <$tmp "s/^.*: //" | sed "s/://g" | sed "s/ /_/" | tr -d '\r' ` mv $x $newname.mov else echo "Cannot process $x, no 'Create Date'" >&2 fi done rm -f $tmp