Chcase

From Christoph's Personal Wiki
Jump to: navigation, search

chcase is a perl script (command line tool) used to rename files in linux. You can change filenames to either all upper or all lower case, or specify perl expressions to operate on the filenames. It was written by "Supermike".

This is a useful command (or "script") for renaming multiple filenames at once.

  • Latest version: 2.0

Features/options

  • Capitalize words or filenames
  • Can recurse through subdirectories
  • Supports special characters
  • Can overwrite existing files
  • Operates on filenames with perl expressions like s/// and tr///
  • Search and replace strings in filenames (eg: remove all spaces)

Usage examples

Note: The following have been tested on version 1.2.

  • these specific files are changed to lower case:
chcase My.DOC *.JPG FileName.txt
  • all files and sub dirs to lower case, start in current dir, recurse:
chcase -rd '*'
  • rename .jpg and .gif files in pics dir to lower case:
chcase -s pics '*.jpg' '*.gif'
  • starting from /tmp/junk and recursing, change files matching this mask to all upper case, overwrite if file exists:
chcase -rous /tmp/junk 'a??b*.txt'
  • renames *.doc files replacing 99dec with jan2000, and replacing all spaces with underscores:
chcase -x 's/99dec/jan2000/' -x 's/ /_/g' '*.doc'
  • removes all non-alphanumeric characters except for '.' and changes the pattern "jpg" to lower case if it isn't already:
chcase -x 'tr/a-zA-Z0-9.//cd' -x 's/jpg/jpg/i' '*'
  • displays directory structure:
chcase -r

Installation

  • Download chcase
  • Make it executable (eg: chmod 755 chcase)
  • Move it to somewhere in your path (eg: mv chcase /usr/local/bin)
  • Read help and examples (eg: chcase --help; chcase -e)

See also

External links