Add dual_rename.sh to make ripping CDs easier
authorColin McCabe <cmccabe@alumni.cmu.edu>
Mon, 15 Feb 2010 03:53:09 +0000 (19:53 -0800)
committerColin McCabe <cmccabe@alumni.cmu.edu>
Mon, 15 Feb 2010 03:53:09 +0000 (19:53 -0800)
dual_rename.sh [new file with mode: 0755]

diff --git a/dual_rename.sh b/dual_rename.sh
new file mode 100755 (executable)
index 0000000..c28584c
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+tmpfile=/tmp/$$.pid
+
+die() {
+    echo $@
+    exit 1
+}
+
+cleanup() {
+    rm -f ${tmpfile}
+    exit
+}
+
+# create temp file
+trap cleanup INT TERM EXIT
+cat > /tmp/$$.tmp 
+
+# do lossless rename
+dirname=`pwd | sed 's_.*/__'`
+lossless_dirname="${dirname} [LL]"
+pushd "../${lossless_dirname}" > /dev/null \
+|| die "couldn't change dir to ${lossless_dirname}"
+bulk_rename.pl -f < /tmp/$$.tmp || die "bulk_rename -f failed"
+
+# do lossy rename
+popd > /dev/null || die "failed popd"
+bulk_rename.pl < /tmp/$$.tmp || die "bulk_rename failed"