For reasons that should be obvious by now, I review the helmet camera video from (some of) our bike rides and extract snapshots of interesting events. VLC auto-names the snapshots along these lines:
-rw-rw-r-- 1 ed ed 4.0M 2016-09-16 16:15 vlcsnap-2016-09-16-16h15m43s49.png -rw-rw-r-- 1 ed ed 3.2M 2016-09-16 16:15 vlcsnap-2016-09-16-16h15m59s181.png -rw-rw-r-- 1 ed ed 2.7M 2016-09-16 16:18 vlcsnap-2016-09-16-16h18m58s125.png -rw-rw-r-- 1 ed ed 3.7M 2016-09-16 18:40 vlcsnap-2016-09-16-18h40m22s7.png -rw-rw-r-- 1 ed ed 3.5M 2016-09-16 18:40 vlcsnap-2016-09-16-18h40m58s132.png -rw-rw-r-- 1 ed ed 3.5M 2016-09-16 18:41 vlcsnap-2016-09-16-18h41m29s181.png -rw-rw-r-- 1 ed ed 3.9M 2016-09-16 18:41 vlcsnap-2016-09-16-18h41m42s60.png -rw-rw-r-- 1 ed ed 3.8M 2016-09-16 18:41 vlcsnap-2016-09-16-18h41m54s146.png -rw-rw-r-- 1 ed ed 3.8M 2016-09-16 18:42 vlcsnap-2016-09-16-18h42m22s206.png -rw-rw-r-- 1 ed ed 3.7M 2016-09-16 18:42 vlcsnap-2016-09-16-18h42m38s58.png
The gap in the timestamp after the first three files reveals a random errand.
First, convert to JPG format, place the results in another directory and, en passant, mash them to a reasonable size:
mkdir /some-useful-directory/Road\ Repair/"Rt 82 and CR 29"
for f in vlcsnap-2016-09-16* ; do convert $f -density 300 -define jpeg:extent=200KB /some-useful-directory/Road\ Repair/"Rt 82 and CR 29"/${f%%.*}.jpg ; done
cd /some-useful-directory/Road\ Repair/"Rt 82 and CR 29"
Replace the first part of the VLC-generated names with relevant identification:
rename 's/vlcsnap-/Rt 82 - /' vlcsnap-2016-09-16-16* rename 's/vlcsnap-/CR 29 - /' vlcsnap*
The directory now contains these files:
-rw-rw-r-- 1 ed ed 193K 2016-09-19 11:36 CR 29 - 2016-09-16-18h40m22s7.jpg -rw-rw-r-- 1 ed ed 192K 2016-09-19 11:36 CR 29 - 2016-09-16-18h40m58s132.jpg -rw-rw-r-- 1 ed ed 193K 2016-09-19 11:36 CR 29 - 2016-09-16-18h41m29s181.jpg -rw-rw-r-- 1 ed ed 193K 2016-09-19 11:36 CR 29 - 2016-09-16-18h41m42s60.jpg -rw-rw-r-- 1 ed ed 194K 2016-09-19 11:36 CR 29 - 2016-09-16-18h41m54s146.jpg -rw-rw-r-- 1 ed ed 196K 2016-09-19 11:36 CR 29 - 2016-09-16-18h42m22s206.jpg -rw-rw-r-- 1 ed ed 196K 2016-09-19 11:36 CR 29 - 2016-09-16-18h42m38s58.jpg -rw-rw-r-- 1 ed ed 195K 2016-09-19 11:36 Rt 82 - 2016-09-16-16h15m43s49.jpg -rw-rw-r-- 1 ed ed 194K 2016-09-19 11:36 Rt 82 - 2016-09-16-16h15m59s181.jpg -rw-rw-r-- 1 ed ed 194K 2016-09-19 11:36 Rt 82 - 2016-09-16-16h18m58s125.jpg
These bursts of Perl regex line noise replace the snapshot timestamp on those files with an ascending sequence number, with separate sequences for each group:
i=1 ; for f in CR* ; do rename -v "s/-1[68]h..m..s\d{1,3}/ - $(( i++ ))/" "$f" ; done
i=1 ; for f in Rt* ; do rename -v "s/-1[68]h..m..s\d{1,3}/ - $(( i++ ))/" "$f" ; done
And then the files make sense:
-rw-rw-r-- 1 ed ed 193K 2016-09-19 13:51 CR 29 - 2016-09-16 - 1.jpg -rw-rw-r-- 1 ed ed 192K 2016-09-19 13:51 CR 29 - 2016-09-16 - 2.jpg -rw-rw-r-- 1 ed ed 193K 2016-09-19 13:51 CR 29 - 2016-09-16 - 3.jpg -rw-rw-r-- 1 ed ed 193K 2016-09-19 13:51 CR 29 - 2016-09-16 - 4.jpg -rw-rw-r-- 1 ed ed 194K 2016-09-19 13:51 CR 29 - 2016-09-16 - 5.jpg -rw-rw-r-- 1 ed ed 196K 2016-09-19 13:51 CR 29 - 2016-09-16 - 6.jpg -rw-rw-r-- 1 ed ed 196K 2016-09-19 13:51 CR 29 - 2016-09-16 - 7.jpg -rw-rw-r-- 1 ed ed 195K 2016-09-19 13:51 Rt 82 - 2016-09-16 - 1.jpg -rw-rw-r-- 1 ed ed 194K 2016-09-19 13:51 Rt 82 - 2016-09-16 - 2.jpg -rw-rw-r-- 1 ed ed 194K 2016-09-19 13:51 Rt 82 - 2016-09-16 - 3.jpg
The hard part, this time around, involved figuring a regex for the timestamp. The trick was to specify a single digit for the milliseconds part, with a repetition count allowing for one-to-three digits.
The Perl regex cheat sheet helped.
The double quotes around the rename search parameter allows the shell to expand the $(( i++ )) gibberish. The double quotes around the file name keep the blank-separated parts together.
At some point I must figure out how to produce leading-zero-filled sequence numbers, which will probably involve a printf.
The ride covered some roads with “2 to 4 foot” shoulders, which seems overly optimistic:

NYSDOT and DCDPW both believe a homeopathic strip of asphalt will cover faults in the travel lane and don’t care that the right side of the strip puts an abrupt ledge along the middle of the minimal and fissured shoulder:

Ah, well, it was a lovely day for a ride …















