Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

All hands to battle stations, rename at will!

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

All hands to battle stations, rename at will!

Build Status

Rename a string in CamelCase, snake_case and ALL_CAPS in code and filenames in one go.


Say you've got a cool hex_clock.cpp:

#ifndef _HEX_CLOCK_H
#define _HEX_CLOCK_H

class HexClock
    int hex_clock();

    int hex_clock_;


Cute! And now.. rename at will! hex_clock hacker_clock

Meet the new shiny hacker_clock.h:


class HackerClock
    int hacker_clock();

    int hacker_clock_;


What it knows to do

rename is like a search/replace engine on steroids, it takes a string to search for, converts it to all possible cases (CamelCase, snake_case and ALL_CAPS), and performs a search/replace with the corresponding case version of the destination string.

For example, hex_clock hacker_clock above, does the following substitutions in text files:

hex_clock --> hacker_clock
HexClock --> HackerClock

Also, by default, the file hex_clock.h is renamed to hacker_clock.h, file rename can be disabled with -f flag, see Usage below.


usage: [-h] [--version] [-w] [--almost-word] [-n] [-d] [-f] [-a]
                 [-V] [-q]
                 SOURCE DEST PATTERN [PATTERN ...]

Rename a string in CamelCase, snake_case and ALL_CAPS in one go

positional arguments:
  SOURCE           source string to be renamed
  DEST             string to replace with
  PATTERN          shell-like file name patterns to process

optional arguments:
  -h, --help       show this help message and exit
  --version        show program's version number and exit
  -w, --word       force SOURCE to match only whole words
  --almost-word    like -w, but also allow for any number of surrounding
  -d, --diff       shows diff instead of modifying files inplace
  -f, --text-only  only perform search/replace in file contents, do not rename
                   any files
  -V, --verbose    be verbose
  -q, --silent     be silent


Python 2.7/3.x will do.

Something went wrong with that request. Please try again.