Added discussion of escaping = in -r and -x contexts.
Inital completion of EXAMPLES section.
1 parent 0033146 commit f6ac49c4761d1b4ca4096f5e61dd35fa837a6dc9
@tundra tundra authored on 16 Jan 2010
Showing 1 changed file
View
61
tren.rst
This option's behavior is modified by the ``-b``,
``-c``, ``-e``, ``g``, ``l``, and ``x`` options.
 
If you need to use the ``=`` symbol *within* either
the old or new string, simply escape it: ``\=``
 
 
-t Test mode, don't rename, just show what the program *would* do
(ignores -q).
 
sXs-2.txt
sXs-3.txt
 
**tren** only accepts Python style regular expressions. Anything
else will cause an error message to be displayed.
else will cause an error message to be displayed.
 
Because Python regular expressions can make use of the ``=``
symbol, you need a way to distinguish between an ``=`` used in a
regular exression and the same symbol used to separate the old
and new operands for the ``-r`` option. Where this symbol needs to
appear in a regular expression, it has to be escaped like this:
``\=``.
 
 
TEMPLATE CONSTRUCTION
---------------------
 
EXAMPLES
--------
 
Here are some common examples of **tren** in action:
Here are some common examples of **tren** in action - the resulting
file name(s) shown to the right as a comment. Study each example
carefully. Small subtleties are introduced in various
adjacent examples to illustrate diffent features of **tren**:
 
 
Simple rename::
 
tren.py
tren.py -r old=New fold.txt log.old # fNew.txt log.New
 
Change file "name"::
 
tren.py
tren.py -b -r old=New fold.txt log.old # fNew.txt log.old
 
Change file "extension"::
 
tren.py
tren.py -e -r old=New fold.txt log.old # fold.txt log.New
 
Rename all instances of a given string::
 
tren.py
tren.py -g -r bin=Bin binary_bin.binbin # Binary_Bin.BinBin
 
Rename, ignoring case::
 
tren.py
tren.py -c -r bin=BIN Binary_bIN.txt # BINary_bIN.txt
 
Rename multiple strings at once::
 
tren.py
tren.py -r log:txt -r New:old New.log # old.txt
 
Rename using regular expressions::
 
tren.py
tren.py -x -r a+=a Saaaaaaaally.doc # Sally.doc
 
Rename a file containing the ``=`` symbol::
 
tren.py -r a\=b=c\=d a=b.txt # c=d.txt
 
Use template::
 
tren.py
tren.py -T /I/ file.1 # 2010-01-12
 
Use template to change file "name"::
 
tren.py
tren.py -b -T /I/ file.1 file.2 # 2010-01-12.1 2010-01-12.2
 
Use template to change file "extension"::
 
tren.py
tren.py -e -T /D/ file.1 # file.20100112
 
Append template text::
 
tren.py
tren.py -a -T ./D/ file.1 # file.1.20100112
 
Prepend template text::
 
tren.py
tren.py -p -T /D/- file.1 # 20100112-file.1
 
Get help::
 
tren.py -h
-----------------------------
 
::
 
$Id: tren.rst,v 1.116 2010/01/16 17:06:00 tundra Exp $
$Id: tren.rst,v 1.117 2010/01/16 19:58:19 tundra Exp $
 
You can find the latest version of this program at:
 
http://www.tundraware.com/Software/tren