This script lets you define rules to rename your files in a specific directory.

Download: replace_filename.py

Usage: replace_filename.py directory search_string replace_string
Options:
  -h, --help            show this help message and exit
  -r, --recursive       recursive mode
  -v, --verbose         verbose output
  -f, --file-only       process only on files
  -d, --directory-only  process only on directories
  -s, --simulate        make a simulation of the renaming
  -e, --use-regex       use input as regex. if regex contains groups, use \1

Examples

Considering the following folder tree

.
|
+-aaa.txt
|
+-asd.txt
|
+-txts
  |
  +-red.TXT
  |  
  +-green.txt

rename all files and directories a -> c

replace_filename.py . a c

uppercase for all txt extension, to apply recursively

replace_filename.py . -r -f .txt .TXT

insert prefix 'holiday_’ for all files whose first letter is 'a’

replace_filename.py . -r -e -f '(a.*)' 'holiday_\1'