Documented -e option.
1 parent 0dc7912 commit 4975c674cf2d4741f0a8ea0ea7a355953881f5db
@tundra tundra authored on 8 Sep 2010
Showing 1 changed file
View
49
tren.rst
(*Default*: Search for string to replace is case sensitive)
 
When looking for a match on the old string to replace,
**tren** will ignore the case of the characters found
in the filename. For example::
in the file name. For example::
 
tren.py -cr Old=NEW Cold.txt fOlD.txt
 
This renames both files to ``CNEW.txt`` and ``fNEW.txt``
the "quiet" and "test" modes::
 
tren.py -tqd -r... -r... file file...
 
-e casetype Force case change to ``casetype``.
 
(*Default*: No forced case.)
 
This option supports a number of ``casetype`` arguments
to transform the case of the file name::
 
c - Capitalize the file name
l - Force file name to lower-case
s - Swap case of file name characters
t - Force file name to title case
u - Force file name to upper-case
 
"Title case" just means that any alphabetic character following
a non-alphabetic character will be capitalized::
 
tren.py -et fee_fi_fo # -> Fee_Fi_Fo
 
Notice that these case transformations are a kind of special
built-in renaming request with one important difference: The
``-i`` "instance" setting is ignored. That's because the
``-e`` option isn't based on replacing an "old" string like the
``-r`` renaming option, but rather operates on the file name as
a whole.
 
There is, however, a way to limit the effect of the case
forcing options because the ``-T`` or "target" option *is*
observed. You can thus limit the which portion of the file
name should have its case changed::
 
tren.py -T4:6 -eu fee_fi_fo # -> fee_FI_fo
 
-f Force renaming even if target file or directory name already
exists.
 
(*Default*: Skip renaming if a file or directory already
to 1000. If you exceed this, you'll get an error message and
the program will terminate.
 
Note that wildcard metacharacters like ``*`` and ``?`` that are
embedded in filenames included this way are expanded as they
embedded in file names included this way are expanded as they
would be from the command shell.
 
You can define an environment variable, ``TRENINCL``, to specify
a path to search to find the named include file(s). ``tren`` will
tren.py -r =MyNewFilename foo #New Name: MyNewFilename
 
Be careful with this one. If you apply it to a list of files or
directories, it's going to try and name them all to the *same* name.
By default, **tren** will refuse to overwrite an existing filename, so
By default, **tren** will refuse to overwrite an existing file name, so
it will stop you from doing this. If you absolutely insist on this
via the ``-f`` option, you'll get a bunch of files ending with
``.backup``. Say you have files ``a``, ``b``, and ``c``::
 
This is not a limitation of **tren** but a consequence of a silly
design decision in these two operating systems. As a practical
matter, the way to avoid this issue is to never do a renaming
operation in OS X or Windows *that only converts case*. Try
to include some other change to the filename to keep the
to include some other change to the file name to keep the
distinction between "old name" and "new name" clear to the
OS. In the worst case, you'll have to resort to something like::
 
tren.py -rA=X Aa.txt
the ``-r`` option. This effectively means "replace
everything" in the existing file or directory name with our
newly concocted naming scheme.
 
Of course, you don't *have* to replace the entire filename when
Of course, you don't *have* to replace the entire file name when
using tokens. It's perfectly legitimate to replace only
a portion of the existing name::
 
tren.py -r file=/MYEAR/MMON//MDAY/-file file-1 file.2
93-...
97-...
98-...
 
The filenames are still preserved in our renaming reqest
The file names are still preserved in our renaming reqest
above, now they're just preceded by the device ID of the
where they live with a trailing ``-`` separator.
 
- ``/FNAME/ Returns Original File- Or Directory Name``
 
tren.py -i -1 -r .jpeg=.jpg *.jpeg
 
 
- Replace Spaces In A Filename With Underbars
- Replace Spaces In A File Name With Underbars
 
Even though spaces are allowed in file names in most OSs, they're
a pain::
 
-----------------------------
 
::
 
$Id: tren.rst,v 1.191 2010/09/07 20:17:23 tundra Exp $
$Id: tren.rst,v 1.192 2010/09/08 17:34:36 tundra Exp $
 
You can find the latest version of this program at:
 
http://www.tundraware.com/Software/tren