remv

Introduction

That's a tool to rename files with the help of regular expressions. It allows one to replace parts of filenames and/or directories, rename them completely, remove files which match a given pattern, change the case of them, use help of external programs, and more.

Options

Here is an excerpt of the help message you will obtain by using the --help option:

Usage: remv [OPTIONS] [PATTERN [REPLACE]] FILE ... 
 
Options: 
    -r          replace PATTERN with REPLACE for each file (default) 
    -m          move files matching PATTERN to REPLACE 
    -d          remove all occurrences of PATTERN 
    -c          capitalize all given files 
    -l          lowercase all given files 
    -u          uppercase all given files 
    -i          ignore case when matching PATTERN 
    -R          be recursive 
    -D          do action on directories as well 
    -I          confirm actions interactively 
    -C          consider REPLACE to be a command, expanding backreferences 
                before and after execution 
    -v          be verbose 
    --dry       don't actually do anything 
    -h, --help  print this message 

Examples

Here are some usage examples:

Replace spaces by underlines:

remv ' ' '_' * 

Do the same with help from sed:

remv -m -C '.*' 'echo "\&" | sed "s/_/ /g"' * 

Move files like 6.1.001 to vim-6.1-001.patch:

remv -m '^6.1.(\d{3})$' 'vim-6.1-\1.patch' 

Capitalize all files:

remv -c * 

Lowercase all files:

remv -l * 

Replace vs. Move

A frequent question is what's the difference between the -r (the default one) and the -m parameter. It's simple: -r will replace what the pattern matched with the replace pattern, while -m will replace the complete filename with the replace pattern. For example, if you have a file named my_file in the current directory, and run the following command:

remv file test * 

my_file will be renamed to my_test. While, if you execute the command:

remv -m file test * 

my_file will be renamed to test.

Download

The following files are available:

Author

Gustavo Niemeyer <gustavo@niemeyer.net>


CategoryProject

remv (last edited 2008-03-03 03:15:11 by GustavoNiemeyer)