[nSLUG] Removing spaces from file names - note, long lines

Stephen Gregory nslug at kernelpanic.ca
Mon Nov 10 21:37:02 AST 2014


On Mon, Nov 10, 2014 at 6:29 PM, Oliver Doepner <odoepner at gmail.com> wrote:
>
> You might find this interesting, too:
> http://odoepner.wordpress.com/2011/10/13/bash-script-to-recursively-sanitize-folder-and-file-names/

That is slick. Particularly this line.

filename_clean="${filename//+([^[:alnum:]_-\.])/_}"


For those of you who like perl there is the perl util "rename." (AKA
/usr/bin/prename on debian.) You feed it a list of files and a perl
regex to transform the file names. As it is a perl regex you can do
just about anything provided you don't mind opening a portal to the
realm of the elder gods.

-- 
sg


More information about the nSLUG mailing list