Difference between revisions of "Chcase"
From Christoph's Personal Wiki
(+"See also") |
(→Installation) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
'''chcase''' is a [[perl]] script ([[:Category:Linux Command Line Tools|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". | '''chcase''' is a [[perl]] script ([[:Category:Linux Command Line Tools|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". | ||
Line 14: | Line 12: | ||
* Operates on filenames with perl expressions like <tt>s///</tt> and <tt>tr///</tt> | * Operates on filenames with perl expressions like <tt>s///</tt> and <tt>tr///</tt> | ||
* Search and replace strings in filenames (eg: remove all spaces) | * 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 <code>.jpg</code> and <code>.gif</code> files in pics dir to lower case: | ||
+ | chcase -s pics '*.jpg' '*.gif' | ||
+ | |||
+ | * starting from <code>/tmp/junk</code> and recursing, change files matching this mask to all upper case, overwrite if file exists: | ||
+ | chcase -rous /tmp/junk 'a??b*.txt' | ||
+ | |||
+ | * renames <code>*.doc</code> files replacing <code>99dec</code> with <code>jan2000</code>, 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 "<code>jpg</code>" 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 == | == Installation == | ||
− | * [http://www. | + | * [http://www.primaledge.ca/chcase Download chcase] |
* Make it executable (eg: <tt>chmod 755 chcase</tt>) | * Make it executable (eg: <tt>chmod 755 chcase</tt>) | ||
* Move it to somewhere in your path (eg: <tt>mv chcase /usr/local/bin</tt>) | * Move it to somewhere in your path (eg: <tt>mv chcase /usr/local/bin</tt>) | ||
Line 22: | Line 44: | ||
== See also == | == See also == | ||
− | * [[ | + | *[[mmv]] |
− | * [[Rename (command)|rename]] | + | *[[Rename (command)|rename]] |
− | == External links == | + | ==External links== |
− | * [http://www. | + | *[http://www.primaledge.ca/chcase.html Official website] — by supermike |
[[Category:Linux Command Line Tools]] | [[Category:Linux Command Line Tools]] |
Latest revision as of 00:47, 14 December 2012
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 replacing99dec
withjan2000
, 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
- Official website — by supermike