Renaming bug?

Jun 24, 2008
Siegen, Germany
How would I accomplish this (I assure you, this is a real-world problem here):

ren `"àsdf (%23%39).pdf"` <new_name>

where <new_name> should be (in this case):

àsdf (#9).pdf

I tried a lot of combinations (quoting with " ` ' @quote[], setdos /x-...) but to no avail.

How would I make a working command into a macro/function?


Staff member
May 14, 2008
I don't think this constitutes a "bug" -- unless you can do it in CMD and you can't in TCC. (Or if the TCC documentation says it should work.)

REN is (severely) constrained by the requirements for compatibility with CMD, which limits the transformations you can make on the target name. Vince has a plugin that allows regex renaming (using a variable function); you might want to look into that.
Jun 24, 2008
Siegen, Germany

Sorry, I was a little unspecific. I wanted to express that the following commands were not working (and grab a solution for my problem):

ren `"àsdf (%23%39).pdf"` "%@urldecode[àsdf (%23%39).pdf]" => àsdf (39).pdf
ren `"àsdf (%23%39).pdf"` `"%@urldecode[àsdf (%23%39).pdf]"` => %@urldecode[àsdf (%23%39).pdf] (not coming as a surprise...)
ren `"àsdf (%23%39).pdf"` "%@urldecode[`àsdf (%23%39).pdf`]" => `àsdf (#9).pdf` (get rid of the backticks, and I'm fine!)

How would I use @urldecode[] with files named like the one above and produce the expected/correct/desired (àsdf (#9).pdf) result? How would I write a macro/alias? The problem lies in the parser's interpretation of the backtick characters (or in my inability to understand the quoting mechanism of TCC...).


I'd like to go w/o any plugins as long as there is a chance to get "it" working with the means provided in TCC itself (this does not go against your plugin!). I simply feel that - at this point - TCC is not working correctly (a feeling btw, that never comes to me when working with bash or zsh - which have their issues as well...).


Staff member
May 14, 2008
It doesn't have anything to do with RENAME, it's not a bug, and it will not be "fixed" (it would break nested variable expansion and make it impossible to use variable arguments in variable functions).

Your first example:

ren `"àsdf (%23%39).pdf"` %@urldecode[àsdf (%23%39).pdf]
passes the string inside the @urldecode function back to the variable expansion parser before @urldecode sees it. So it is converted to:

ren `"àsdf (%23%39).pdf"` %@urldecode[àsdf (39).pdf]
before expanding @urldecode, and before REN sees it.

One simple workaround is:

ren `"àsdf (%23%39).pdf"` %@strip[^`,%@urldecode[`àsdf (%23%39).pdf`]]
Jun 24, 2008
Siegen, Germany
Embracing %@strip[^`,%@urldecode[`àsdf (%23%39).pdf`]]" with "s (making it ren `"àsdf (%23%39).pdf"` "%@strip[^`,%@urldecode[`àsdf (%23%39).pdf`]]") actually works but this whole construct is pretty awkward.

How about changing the variable expansion parser to also accept []s for positional variables?
The following obviously already works:

set a=b
echo %[a]x
echo %ax

Doing so would let %23%39 go unchanged but %[2]3%[3]9 would get converted to 39 (like now). The whole rename thing would then become:

ren `"àsdf (%23%39).pdf"` "%@urldecode[àsdf (%23%39).pdf]"

EDIT Correction: ... Doing so would - obviously - change "%23%39" to ""! So - for positional variables a more sophisticated solution would be necessary like "if it's not embraced in []s and it's more than two digits wide let it go unchanged"...

Regardless of the above, could you please detail the exact sequence in which a command line is evaluated?


Staff member
May 14, 2008
How about changing the variable expansion parser to also accept []s for positional variables?

That would require a major rewrite, and it would also break positional arguments > 9.

Regardless of the above, could you please detail the exact sequence in which a command line is evaluated?

It's documented in detail in the help; see "Command Parsing".
Similar threads
Thread starter Title Forum Replies Date
JohnQSmith Regex renaming Support 2
P Renaming with a RegEx Support 1
J Extended directory search - cure by renaming tcmd.ini Support 10
S GPF after successfully renaming directories on an ftp server Support 2
M More file-renaming problems involving commas... Support 0
M Another problem with renaming files... Support 3
P Renaming files with regex. Support 6
gunkelkarl renaming files Support 14
Dick Johnson v28 Cosmetic Bug Support 0
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
R strange bug? Support 7
Jay Sage Bug With Flow Control and/or Command Grouping Support 2
M Server 2019 Bug with @execstr? Support 14
R bug _ypixels in BDEBUGGER Support 6
E Fixed Bug with DIR /Z displaying descriptions Support 8
E Text copy bug Support 1
x13 SETARRAY /Z bug Support 6
Gamegod ffind bug with chinese Support 2
Dick Johnson cdd - is this a bug or a feature? Support 7
P "Set" command behavior - a bug? Support 3
nikbackm TCC 20 variable expansion bug Support 6
gentzel Bug launching external commands in 20.11.43 Support 11
R Is this a bug in SETARRAY? Support 2
M Windows Installer bug? Support 4
vefatica @SCRIPT bug persists Support 4
M Little bug, big consequences .. Support 6 Once again the Can't Install bug bites... Support 2
gentzel Fixed dirs +n bug in 20.0.12 x64 Support 2
M Bug in Windows 10, when adding symbol to task bar Support 6
Alpengreis [Bug?] View (V) Prefs Error (TC 18.00.27 x64) Support 4
D WAD Minor Post Installation Bug in V18 Support 1
I Possible Bug: History /n Returns Nothing Support 3
samintz WAD Weird REN bug Support 6
Jay Sage WAD Possible Bug in Batch Parameters Support 7
G Bug? TCC 16.03.55 Console Palette Support 4
S Return of FTP copy bug in 16.02.48 Support 12
S XenForo bug Support 3
D TCMD16 Delete Toolbar Button bug Support 7
keithg1964 WAD 16.0027 Alias /rz bug Support 8
rfaquino WAD Apparently a bug when expanding environment variable %ProgramFiles(x86) Support 2
T Documentation @LINE[CON,n] @LINES[CON] not documented (bug?) Support 4
H TIMER bug Support 4
G Fixed @REREPLACE bug Support 15
G WAD PDIR @IF bug, @WORD bug Support 8
T Bug in TCMD but not in TCC Support 8
M WAD A complaint regarding a very irritating TCC installation behavior... (Bug?) Support 4
nickles Redirect bug? Support 4
nickles UrlDecode() bug? Support 3
P WAD Bug in TC v 13.03 build 39 x64 Support 1
S Debug feature bug? Support 17

Similar threads