ref: d400e426eb04cfc4cb78fa82e7bcdc20150f3305
dir: /bin/bag/
#!/bin/rc -e
rfork en
fn bag {
file = $1
h = `{sha1sum $file | sed 's/(..)(....).*/\1 \2 &/'}
b = $h(1)
f = $b^/^$h(2)
h = $h(3)
if(~ $force 1 || ! test -e $bag/$f){
mkdir -p $bag/$b
>>$bag/$f.tag {
echo 'hash:' $h
echo 'file:' $file
echo 'date:' `{date -um}
echo 'tags:' $tags
echo 'note:' $note
}
touch $bag/$f
fcp $file $bag/$f
}
if not
>[1=2] echo already bagged
echo $bagurl/$f
}
flagfmt = 'f:force,t:tags tags,m:note message'; args = 'file ...'
eval `''{aux/getflags $*} || exec aux/usage
if(~ $#bag 0)
bag = /n/bag
if(~ $#bagurl 0)
bagurl = http://a-b.xyz
ramfs -u -m /mnt/ram
files = ($*)
if(~ $#files 0){
cat /fd/0 >/mnt/ram/stdin
files = (/mnt/ram/stdin)
}
9fs bag
for(f in $files)
bag $f