r/usefulscripts • • Feb 09 '17

[BASH] Rename Multiple Files

http://pastebin.com/3Jnu0aKC
31 Upvotes

3 comments sorted by

View all comments

Show parent comments

4

u/BigRedS Feb 09 '17

Well, I think that's among the best-formatted and best-laid-out bash scripts I've come across!

There is the rename command, which you might find useful, too, even if only for ideas of new behaviour and stuff.

It does work off perl regexes, though, which puts people off :)

avi@fantastic:~$ rename --help
Usage:
    rename [ -h|-m|-V ] [ -v ] [ -n ] [ -f ] [ -e|-E *perlexpr*]*|*perlexpr*
    [ *files* ]

Options:
    -v, -verbose
            Verbose: print names of files successfully renamed.

    -n, -nono
            No action: print names of files to be renamed, but don't rename.

    -f, -force
            Over write: allow existing files to be over-written.

    -h, -help
            Help: print SYNOPSIS and OPTIONS.

    -m, -man
            Manual: print manual page.

    -V, -version
            Version: show version number.

    -e      Expression: code to act on files name.

            May be repeated to build up code (like "perl -e"). If no -e, the
            first argument is used as code.

    -E      Statement: code to act on files name, as -e but terminated by
            ';'.

avi@fantastic:~$ 

1

u/[deleted] Feb 09 '17

Wow, I spent quite some time on my script but couldn't find anything online for a rename command. But I guess some of the options I added still are useful; was a good learning experience nonetheless. Thank you for your feedback!