shithub: img

ref: 14c50ed0b3050906015c48c987460865bfd7f30c
dir: /sdrip/archive.rc/

View raw version
#!/bin/rc

. ./fns.rc

{lscmd >[2]/dev/null} | awk -F_ 'BEGIN{
	dirs["misc"] = 1
}
/^misc\./{
	printf "mv -n %s %s/img/misc/%s\n", $0, ENVIRON["HOME"], $0
	next
}
{
	year=substr($1, 1, 4)
	month=substr($1, 5, 2)
	dirs[sprintf("%s/%s", year, month)] = 1
	mvs[$0] = sprintf("%s/img/%s/%s/%s", ENVIRON["HOME"], year, month, $0)
}
END{
	printf "flag e +\n"
	for(d in dirs)
		printf "mkdir -p %s/img/%s\n", ENVIRON["HOME"], d
	for(k in mvs)
		printf "mv %s %s\n", k, mvs[k]
	printf "exit 0\n"
	exit(0)
}' | rc