subst update (1.1.3)

So, after a couple of idle years I made an update to my subst script. Although I use it everyday there were still some glitches here and there. For one, I just could not rename files with spaces in them. Very annoying. Also it was unflexible in that I could not use additional perlmodules when using /e. STDIN was not supported among other minor stuff.

So, the new version fixes all this, see the link above. Download, rename it (remove the .txt extension) and put it into your bin directory. Usage:

Usage: subst  [-M <perl module>] [-t] -r 's/old/new/<flags>' [ -r '...', ...] [<file> ...     | /regex/]
       subst  [-M <perl module>] [-t] -m 's/old/new/<flags>' [ -m '...', ...] [<file|dir> ... | /regex/]

 -r        replace contents of file(s)
 -m        rename file(s)
 -M        load additional perl module to enhance /e functionality.
 -t        test mode, do not overwrite file(s)

 - replace "tom" with "mac" in all *.txt files:
   subst -r 's/tom/mac/g' *.txt

 - rename all jpg files containing whitespaces:
   subst -m 's/ /_/g' '/.jpg/'

 - decode base64 encoded contents
   subst -M MIME::Base64 -r 's/([a-zA-Z0-9]*)$/decode_base64($1)/gem' somefile

 - turn every uri into a link
   subst -M "Regexp::Common qw /URI/" -r 's#($RE{URI}{HTTP})#<a href="$a">link</a>#g' somefile

If <file> is -, STDIN will be used as input file, results will be printed
to STDOUT. -t does not apply for STDIN input.

Substitution regex must be perlish. See 'perldoc perlre' for details.

Version: 1.1.3. Copyright (c) 2002-2014 - T.v.Dein <tom AT linden DOT at>

So, in order to remove spaces of filenames, I can now just issue:

subst -m 's/ /_/g' '/\.mp3$/'

As you can see, instead of giving a shell wildcard as last argument, I provide a regex, which will be resolved by the script itself from the current directory. Bam!