diff --git a/tren.py b/tren.py index c0f7553..9db8490 100755 --- a/tren.py +++ b/tren.py @@ -8,7 +8,7 @@ PROGNAME = "tren.py" BASENAME = PROGNAME.split(".py")[0] PROGENV = BASENAME.upper() -RCSID = "$Id: tren.py,v 1.169 2010/03/06 01:31:07 tundra Exp $" +RCSID = "$Id: tren.py,v 1.170 2010/03/06 01:38:28 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -107,6 +107,7 @@ TOKCMDEXEC = "`" # Delimiter for command execution renaming tokens TOKDELIM = "/" # Delimiter for all renaming tokens TOKENV = "$" # Introducer for environment variable replacement tokens +TOKFILNAM = "F" # File Name replacement token # Internal program state literals @@ -713,9 +714,20 @@ for r in rentokens: + ### + # File Attribute Renaming Tokens + ### + + if r[2] == TOKFILNAM: + r[2] = os.path.basename(target) + + ### + # System Renaming Tokens + ### + # Environment Variable replacement token - if r[2].startswith(TOKENV): + elif r[2].startswith(TOKENV): r[2] = os.getenv(r[2][1:]) # Command Run replacement token @@ -750,12 +762,16 @@ else: r[2] = output.replace("\n", "") + ### # Unrecognized renaming token + ### else: ErrorMsg(eTOKUNKNOWN % (TOKDELIM + r[2] + TOKDELIM)) - # Do the actual replacement + ### + # Successful Lookup, Do the actual replacement + ### renstring = renstring[:r[0]] + r[2] + renstring[r[1]+1:]