Plan 9 from Bell Labs’s /usr/web/sources/contrib/quanstro/cameracp

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc
targ=()
fn sigint quit{
	if(test -d $targ)
		rm $targ>[2=]
}
fn datefmt{
	x=`{date}
	m=(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
	for(i in `{seq -w 1 12})
		if(~ $m($i) $x(2))
			j=$i
	n=$x(3)
	if(~ $n ?)
		n=0$n
	echo $x($#x)^$j$n
}

if(! test -d /n/camera)
	camera:
9fs other

old=`{
	cd /n/other/pictures
	echo 20*/*.jpg |
		tr ' ' '\x0a' |
		sed 's;.*/([0-9]+)\.jpg;\1;g'  |
		sort -n
}

cd /n/camera/DCIM/101CANON
f=`{echo *.JPG | tr ' ' '\x0a' | sed 's/IMG_([0-9]+)\.JPG/\1/'}
g=()

for(i in $f)
	if(! ~ $i $old)
		g = ($g $i)
fmt=`{datefmt}
mkdir -p /n/other/pictures/$fmt

while(~ 1 1){
	while(! ~ $#g 0 &&
		cp IMG_^$g(1)^.JPG /n/other/pictures/$fmt/$g(1)^.jpg){
		g = $g(2-)
	}
	if(~ $#g 0)
		break
	# usb sucks.
	echo -n 'return after physical usb reset [' ^ $#g ^ ']: '
	read>/dev/null
	camera:
	cd /n/camera/DCIM/101CANON
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].