| |
---|
| | foOO -> foOx # Final name |
---|
| | |
---|
| | In other words, each incremental renaming request honors the |
---|
| | current state of the ``-T`` option. To turn off targeted |
---|
| | renaming - that is, make the whole file name the target again, |
---|
| | renaming - that is, make the whole file name the target again - |
---|
| | simply include ``-T :`` on the command line. All renaming requests |
---|
| | to the right of it will then target the whole name:: |
---|
| | |
---|
| | tren.py -T -1 -r=OO -T: -rO=x foo # Yields: foxO |
---|
| |
---|
| | |
---|
| | |
---|
| | Each character in the name has an "index" or number that |
---|
| | tells you what position is occupies in the name. You can |
---|
| | count from the *left end* of the name starting with 0: |
---|
| | |
---|
| | ========= =============== |
---|
| | count from the *left end* of the name starting with 0:: |
---|
| | |
---|
| | Character Index From Left |
---|
| | --------- --------------- |
---|
| | |
---|
| | a 0 |
---|
| | b 1 |
---|
| | ... |
---|
| | x 8 |
---|
| | t 9 |
---|
| | ========= =============== |
---|
| | |
---|
| | |
---|
| | You can also count backwards relative to the *right end of |
---|
| | the name*: |
---|
| | |
---|
| | ========= ================ |
---|
| | the name*:: |
---|
| | |
---|
| | Character Index From Right |
---|
| | --------- ---------------= |
---|
| | |
---|
| | a -10 |
---|
| | b -9 |
---|
| | ... |
---|
| | x -2 |
---|
| | t -1 |
---|
| | ========= ================ |
---|
| | |
---|
| | |
---|
| | Notice that left-relative indexes are positive numbers beginning with |
---|
| | 0, but right-relative indexes are are negative numbers beginning at -1. |
---|
| | |
---|
| | So, what's a slice? A slice is a way of specifying *a range of one or more values*. |
---|
| | In the case of the ``-T`` argument, "values" means "positions in the name string |
---|
| | targeted for renaming." In the case of the ``-i`` argument, "values" means |
---|
| | In the case of the ``-T`` option, "values" means "positions in the name string |
---|
| | targeted for renaming." In the case of the ``-i`` option, "values" means |
---|
| | *which instances of a given string should be renamed*. |
---|
| | |
---|
| | In our example above, the ``bcd`` portion of the name could be |
---|
| | defined several different ways:: |
---|
| |
---|
| | -9:-6 |
---|
| | |
---|
| | The general form of a slice is:: |
---|
| | |
---|
| | first character/instance:stop on this character or instance |
---|
| | first character/instance:stop on this character/instance |
---|
| | |
---|
| | This can be tricky to get used to. The number on the righthand side |
---|
| | *is not included in he slice* - it is where the slice *ends*. |
---|
| | |
---|
| | There are other shortcut forms of slice notation:: |
---|
| | |
---|
| | :3 # Same as 0:3 |
---|
| | 3: # Start with 4th char/instance and go through, and including last one |
---|
| | 3: # From 4th char/instance through/including end |
---|
| | : # All chars/instances are included in the slice |
---|
| | |
---|
| | In short, slices are a compact way to specify a range of things. If |
---|
| | you specify a slice that makes no sense like ``-4:3``, **tren** will |
---|
| |
---|
| | ----------------------------- |
---|
| | |
---|
| | :: |
---|
| | |
---|
| | $Id: tren.rst,v 1.195 2010/11/16 20:22:12 tundra Exp $ |
---|
| | $Id: tren.rst,v 1.196 2010/11/16 20:31:33 tundra Exp $ |
---|
| | |
---|
| | You can find the latest version of this program at: |
---|
| | |
---|
| | http://www.tundraware.com/Software/tren |
---|
| |
---|
| | |