Added OTHER PROGRAM SEMANTICS section.
Fixed some examples.
1 parent 62a5c2c commit b04a867c73c7769bd0d7a68433285d69e0502ef8
@tundra tundra authored on 20 Jan 2010
Showing 1 changed file
View
41
tren.rst
contents or type of file. By default, **tren** does renaming
in the entire filename *including* the extension. For example
doing this::
 
tren.py -r eg=ug peg.jpeg
tren.py -g -r eg=ug peg.jpeg
 
Renames the file to ``pug.jpug`` .. probably not what you want.
 
The ``-b`` option tells **tren** to only perform string renaming
in the actual "name portion" of the filename thereby
cirumventing problems like this::
 
tren.py -b -r eg=ug peg.jpeg # Renames file to pug.jpeg
tren.py -g -b -r eg=ug peg.jpeg # Renames file to pug.jpeg
-C Do case-sensitive renaming
 
(*Default*: This is the program default)
- All instances of one or more strings in the form ``ss`` would
be replaced with ``S``.
 
 
OTHER PROGRAM SEMANTICS
-----------------------
 
It's important to understand some subtleties of just how **tren**
works, particularly if you intend to create complex, multi-replacement
command lines:
 
- Command line processing is from left to right. As we saw in the
`COMMAND LINE TOGGLES`_ above, this means the options can be
different for each renaming operating you specify.
 
- Regular expression processing is unaffected by the ``-g / -1``
(greedy replace) and ``-c / -C`` (ignore case) options. That's
because there are regular expression mechanisms for achieving the
same thing. More importantly, if you've selected regular
expression matching, it's probably because you want very fine
grained control of the renaming defined by the regex. In short,
regular expression matching always takes place on the *original
characters* of the target portion of the name and does replacement
as called for in the regex itself.
 
- **tren** processes each renaming string in the following
manner:
 
1) Select the target portion of the filename for
renaming (all, name only, extension only).
 
2) Replace all renaming tokens with their equivalent
text in both the ``old`` and ``new`` renaming strings.
 
3) If ``-c`` is in effect, collapse the target and the ``old``
renaming string to *lower case* before checking for a match.
 
4) Replace the first- (default and ``-1``) or all (``-g``) instances
of ``old`` with ``new``.
 
 
RENAMING TOKENS: THE GORY DETAILS
---------------------------------
-----------------------------
 
::
 
$Id: tren.rst,v 1.129 2010/01/20 21:35:07 tundra Exp $
$Id: tren.rst,v 1.130 2010/01/20 22:26:26 tundra Exp $
 
You can find the latest version of this program at:
 
http://www.tundraware.com/Software/tren