[main]  

RenameFiles

Documentation

Usage

    RenameFiles OPTIONS ACTION FILES
    RenameFiles -S OPTIONS ACTIONARGS -- FILES

Description

    Rename(move) files or directories according to a renaming function 
    specified by ACTION.

Options

    -c, --case-insensitive  assume a file system with case insensitive file 
                            names
    -D, --apply-to-dir      apply renaming function ACTION to the complete
                            filename (including path/directories) (default:
                            apply only to the basename of a filename)
    --help                  display short help text
    -i, --interactive       confirm before renaming
    --man, --manual         display complete help with examples etc.
    -n, --dry-run           don't actually rename files
    -p, --parent-dirs       create all parent directories for new file names
                            if needed
    -q, --quiet             don't print names of files to rename
    -S                      use syntax ACTIONARGS -- FILES rather than put 
                            the whole ACTION construct into a single argument
    -v, --verbose           be a bit verbose
    -V, --version           output version information and exit

Notes

    1 ACTION: input must come from stdin, output must go to stdout.
    2 ACTION can be a piping construct.
    3 If the ACTIONARGS syntax is used:
      - arguments not prefixed with "@" are put into quotes
      - arguments prefixed with "@" are not put into quotes, and the "@" is
        removed from the argument.
    4 If ACTION fails, no changes will be made.
    5 If ACTION yields an empty string, the file won't be renamed.
    6 If ACTION yields the original filename, the file won't be renamed.
    7 Already existing files won't be overwritten.

Examples

    Modify the file name extension of files named *.cc to *.cpp:
        RenameFiles "sed 's/\\.cc\$/.cpp/ig'" *.cc

    Rename files by changing all spaces (" ") to underscores ("_") and all 
    upper case letters to lower case letters:
        RenameFiles "sed 's/ /_/g' | tr [:upper:] [:lower:]" *

    Same as above but using the -S option:
        RenameFiles -S sed 's/ /_/g' "@|" tr [:upper:] [:lower:] -- *

    Move files matching "LHS--RHS.txt" into subdirectories "LHS"
    (renaming them to "RHS.txt"). Create needed directories if they 
    do not yet exist. Don't really execute the commands:
        RenameFiles --verbose --parent-dirs --dry-run \
            "sed 's,\(.*\)--\(.*\.txt\),\1/\2,'" *

Bugs

    - only tested with bash
    - it is quite slow
    - (more: see lines in script file marked with BUG)

See Also

    man/perldoc rename

Source Code

License: GPL, Version 2 (or later version).

  [main]  
DaicasWeb v.1.50.0102  //   Daniel Käps  //   March 31, 2005  //   Impressum / Imprint 
http://www.daicas.net/programming/RenameFiles.html