shithub: rc

ref: c1a707427fbbb5129e467516fc671e976ee3e398
dir: /saname/

View raw version
#!/bin/rc

# sanitize filenames

c = ␣

while(! ~ $#* 0) {
	switch($1) {
	case -c
		shift
		c = $1
	}
	shift
}

n = '
' # need explicit newline for multi-line input
#tr ' _{[<()>]}&' $"c^'\-««««»»»»+' | tr -cd '[a-zA-Z¡-￿0-9_\-./,]+'^$"n

ifs='
'
while(name=`{read}) {
	echo mv $name `{echo $name | tr ' _{[<()>]}&' $"c^'\-««««»»»»+' | tr -cd '[a-zA-Z¡-￿0-9_\-./,]+'}
}

# simple usage:
# ls | saname | rc

# advanced usage:
# ls | saname | awk '{print "cp", $2, "/usr/ethan/src/reading/awk-89k/" $3}' | rc

# not sure about quoting.
# maybe should run ls in here
# probably should have options to cover advanced usage