diff --git a/tren.rst b/tren.rst index 7da6268..e9fc809 100644 --- a/tren.rst +++ b/tren.rst @@ -40,7 +40,7 @@ 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. @@ -48,7 +48,7 @@ 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 @@ -518,6 +518,41 @@ 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 @@ -958,7 +993,7 @@ :: - $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: