WAD Weird REN bug

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
I ran into an issue the other day with REN. It seems the issue exists in V16 as well as V17.

I had a handful of files named ECCTOOL* and I wanted to rename then to FKTOOL*.

The rename seems to take place in-place and characters are left over or removed. Since FK has 1 fewer letter than ECC the resulting renamed file has an extra character.

ECCTool ==> FKTooll

When I went to rename them back, I used REN FK* ECC* and it replaced FKT with ECC resulting in files named ECCool* instead of ECCTool*.
 
May 20, 2008
11,437
99
Syracuse, NY, USA
It goes back farther that that. It's probably WAD.
Code:
v:\> ver

4NT  8.02.106  Windows Vista [Version 6.1.7601]

v:\> touch /c abcdefgh
2014-11-13 11:16:48.199  V:\abcdefgh

v:\> ren ab* xyz*
V:\abcdefgh -> V:\xyzdefgh
  1 file renamed

v:\> ren xyz* ab**
V:\xyzdefgh -> V:\abzdefgh
  1 file renamed
 
Jun 2, 2008
376
2
Newton, MA
I wrote a BTM script that I call REN-SUB, to handle this. Here is the syntax message it produces when invoked with too few arguments:

TCC(17.00.52): C:\commands\bat>ren_sub

This program renames files by substituting one string for another the
first time it occurs in the name. The syntax is as follows:

SYNTAX: REN_SUB filespec old_string new_string [/n]

For example,

REN_SUB abc13-def.txt 13 2013

would result in the file being renamed to abc2013-def.txt

If there is an optional fourth argument, /n, then the command only echos
the rename commands that would be performed.


Here is the script contents (suggestions for improvements are most welcome!):

Code:
@echo off

if %# LT 3 goto syntax

set testflag=0

if "%4" EQ "/n" set testflag=1

set strlen=%@len[%2]

do file in /a:-d-h %1

  set startpos=%@index[%file,%2]
  if %startpos EQ -1 iterate

  echo.
  set continuepos=%@eval[%startpos + %strlen]
  set newname=%@instr[0,%startpos,%file]%3%@instr[%continuepos,%file]

  iff %testflag EQ 0 then
  *ren %file %newname
  else
  echo `  `*ren %file %newname
  endiff

enddo

quit

:syntax

text

  This program renames files by substituting one string for another the
  first time it occurs in the name. The syntax is as follows:

endtext

echo `  `SYNTAX: REN_SUB filespec old_string new_string [/n]

text

  For example,

  REN_SUB abc13-def.txt 13 2013

  would result in the file being renamed to abc2013-def.txt

  If there is an optional fourth argument, /n, then the command only echos
  the rename commands that would be performed.
endtext

quit
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
I tried the following rename command and got mixed results. It basically just renamed one file.

Code:
11/12/2014  16:12           8,192  FKtool.exe
11/12/2014  16:12             381  FKtool.exe.intermediate.manifest
11/12/2014  19:09              85  FKtool.lastbuildstate
11/12/2014  19:09          72,442  FKtool.obj
11/12/2014  16:12         273,408  FKtool.pdb
11/11/2014  20:45             713  FKtool.vcxprojResolveAssemblyReference.cache
11/11/2014  20:45               0  FKtool.write.1.tlog
11/12/2014  19:09           9,728  FKtool64.exe
11/12/2014  19:09             381  FKtool64.exe.intermediate.manifest
11/12/2014  19:09         265,216  FKtool64.pdb

ren ::FK(.*) ::ECC\1

11/11/2014  20:45             713  ECCtool.vcxprojResolveAssemblyReference.cache
11/12/2014  16:12           8,192  FKtool.exe
11/12/2014  16:12             381  FKtool.exe.intermediate.manifest
11/12/2014  19:09              85  FKtool.lastbuildstate
11/12/2014  19:09          72,442  FKtool.obj
11/12/2014  16:12         273,408  FKtool.pdb
11/11/2014  20:45               0  FKtool.write.1.tlog
11/12/2014  19:09           9,728  FKtool64.exe
11/12/2014  19:09             381  FKtool64.exe.intermediate.manifest
11/12/2014  19:09         265,216  FKtool64.pdb
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
Just to clarify, that rename command says it renamed 9 files. But it actually only renamed 1.

It works correctly in V16
 
Similar threads
Thread starter Title Forum Replies Date
Dick Johnson Weird Color Problem Support 8
vefatica BEEP - weird on two machines Support 8
JohnQSmith Weird DIR output (missing lines) Support 1
M WAD Another weird copy command errror... Support 2
D WAD Multiple TEE causese weird variable scoping? Support 7
M Weird @Index function result... Support 7
S Weird tab completion in command line Support 2
dcantor Weird interaction with Task Scheduler Support 5
J weird issues in TC10.00.55 Support 4
Jesse Heines Using Regular Expressions with the REN commanc Support 8
C Documentation Help Nit. REN / RENAME Support 0
D How to? Use regular expression with REN? Support 2
vefatica REN and NTFS streams? Support 3
samintz REN implied .* Support 2
F Regexes in REN/MOVE/… commands seem to not work at all Support 3
D How to? Wildcards as sets - looping issue with FOR and REN Support 7
S REN and FOR %a with files Support 8
nickles REN bug Support 11
Phileosophos ren /s does not process subdirectories Support 3
M Ren command confusion Support 13
S Strange REN problem - non-English characters Support 3
T REN a TCC Tab from command line Support 9
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
fishman@panix.com 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
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

Similar threads