shithub: rc

Download patch

ref: ec001e37d60158a50634db11b7e5353c9d12d18f
parent: 62b0682919ca0b7842faa3c60a8127f70c0a6996
author: sl <sl@x1yg3>
date: Sun Jul 6 19:11:29 EDT 2025

add saname

--- a/INDEX
+++ b/INDEX
@@ -53,9 +53,9 @@
 r - setup environment and run rio.
 rag - save image under http://notreally.info/transport/spacecraft/ragnarok/img/
 rrss.barf - Dump RSS feeds into werc/apps/barf entries.
+saname - sanitize filenames
 sparkline - create a sparkline (by anth)
 t - run whichever torrent program is preferred on unix or 9front.
-tablet - launch aux/tablet and aux/wacom
 tobit - convert image to image(6) format
 todos - cook text
 toface - convert image to face(6) format
--- /dev/null
+++ b/saname
@@ -1,0 +1,34 @@
+#!/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
--