Unix Magic Trick: Rename stuff in bulk

Here’s a magic-trick I rock from time to time. I only graze the basic abilities of the “rename” program, but even in my basic use of it, I find it super helpful.

In this case, I had a situation where my eBooks had been resorted from a massive flat directory in to one containing sub-dirs named with the prefix “Categories – “. I might have sorted them in another manner if I didn’t know about the rename command. When I was done sorting and thus left with my category-based directories, I then wanted to rename each dir to dump the prefix.

A simple call to rename is all it takes:
rename "s/[what to find]/[what to replace it with]/" *

Read more “Unix Magic Trick: Rename stuff in bulk”

Multi-threaded tar/bzip2

I often find myself banging my head against a wall watching tar compress with a single execution thread. PBZIP2 is the solution to that problem.

Here’s my few recipes for using this:

Compress: tar cf archive.tar.bz2 --use-compress-prog=pbzip2 archive/
Uncompress: pbzip2 -dvc archive.tar.bz2 | tar x