bash

terminal batch rename (Linux)
Wed 15 July 2015 bash batch Linux , 0 comments
Mon 27 July 2015

My laptop is running Ubuntu 15.04 and lately I had to do some batch file renaming. No sweat, I searched online for a bit and found what I was looking for: the rename program written in Perl. Pretty cool (I said to my self), now I can do a bunch of renames super easily. But little did I know that on the machine (doesn’t run Ubuntu) I’m working at the office most of the time… there is no rename Perl program, there is a rudimentary rename program, but not satisfactory enough (and ancient as well for this era: written in 2000 as per it’s man page). Now the problems start…

Searching online, I found this nifty trick you can use with another (super Linux) program: sed. You can easily rename programs with the following (piped) commands:

ls {f_pattern} | sed 'p;s/{s_patternN}/{r_patternN}' | xargs -n2 mv …