Regex problem: \xnn not recognized as a hex character


Jul 6, 2008
I started a new thread. The old one was getting very long. The subject is the same.

old coot
May 23, 2010 13 0

Yesterday at 7:21 AM

Sorry to resurrect this thread, but I'm still having troubles in the same (or a very similar) vein. Suppose I want to add an extension to all files whose names are wholly alphabetic (A-Z). My directory looks like this:
12/16/2018 3:05 0 FILE.exe
12/16/2018 3:05 0 FIRST
12/16/2018 3:05 0 NOTTHI~1 NOT THIS ONE
12/16/2018 3:05 0 SECOND
12/16/2018 3:05 0 TEXT.txt
12/16/2018 3:05 0 THIRD

So my rename should work on the files named FIRST, SECOND, and THIRD. But the obvious commands (below) do not work:


ren ::^([a-z]+)$ ::\1.txt
ren "::^([a-z]+)$" "::\1.txt"
ren "::^([a-z]+)$" "::\{1}.txt"
The first one wants to work on all the files (and it succeeds in adding an extension to those files that already have an extension). For the files that should be renamed, all three commands want to rename them to the same name!

As mentioned above, I'm using Perl REs.

So get out the mallets and beat some understanding into my thick skull. Please.

Try this in v23 or v24:
v24.00.26_$dir /k /m /h *
11/11/2017   4:00             270  DummFNames.txt
12/17/2018   2:17               3  file.exe
12/17/2018   2:17               3  first
12/17/2018   2:18               0  NOT THIS ONE
12/17/2018  22:05              46  RegxTest.btm
12/17/2018   2:17               0  SECOND
12/17/2018   2:18               0  Text.txt
12/17/2018   2:17               0  THIRD

v24.00.26_$ren /n "::^([^ ^.]+)$" "::\1.txt"
D:\BAT\test05\first -> D:\BAT\test05\first.txt
D:\BAT\test05\SECOND -> D:\BAT\test05\SECOND.txt
D:\BAT\test05\THIRD -> D:\BAT\test05\THIRD.txt
     3 files would be renamed
With your file names it's not clear you actually need the [a-z].
Similar threads
Thread starter Title Forum Replies Date
old coot Regex problem: \xnn not recognized as a hex character Support 12
D Regex problem Support 17
F %@regex["^-","-a"] returns 0, "^-" =~ "-a" is false (no match) Support 4
JohnQSmith Regex renaming Support 2
vefatica TPIPE: unbalanced escaped quotes in a regex? Support 5
R Regex using ^ Support 2
T Regex engine doesn't recognize native DOS line endings Support 2
P Simple RegEx copy Support 9
samintz WAD Regex Analyzer Support 1
D How to? Use typed envars using regex. Support 3
P Renaming with a RegEx Support 1
R How to? use @everything perl regex Support 2
C v18 regex help please Support 1
C Font of RegEx Analyzer Support 0
mikea How to? Regex match when there shouldn't be (?) Support 18
JohnQSmith Fixed Copying with regex (several issues) Support 7
D Help needed to get a regex to work Support 3
thedave WAD Regex match on \h Support 5
Ville Regex & conditionals Support 9
samintz Regex Rename Support 2
vefatica @REGEX: behavior vs. documentation Support 2
vefatica @REGEX revisited Support 4
vefatica @REGEX question Support 6
vefatica Regex question Support 5
B Regex and Replace Support 6
Stefano Piccardi detecting BOM, FFIND multibyte regex Support 18
dcantor FFIND syntax -- is /E"regex" /X supported? Support 2
P Renaming files with regex. Support 6
B "Fun" with DO and Regex Support 12
P Need to use a regex in a "for" loop. Support 54
Dick Johnson Weird Color Problem Support 8 Problem with 27.15 Support 2
M Problem with VSDevCmd.bat in VS 16.7.3 Support 0
R Problem with @INT[ value] in V26 Support 9
M Selecting test "off by one" problem in Take command Support 4
Alpengreis UTF-8 problem in TCC related to Python Support 7
K_Meinhard Small problem in german IDE 26 Support 3
B Problem with color in nested shells Support 1
Joe Caverly Problem creating and switching to a DESKTOP Support 9
vefatica Another popup problem Support 10
Alpengreis ffind dialog (/W) problem Support 4
Alpengreis [TCMD v25.00.24] Small space problem with the DE translation in Prefs-GUI Support 1
Alpengreis [TCMD v25.00.24] Problem with copy and paste and the # char via mouse in TCC Support 6
A Problem with functions @int @decimal and identifying Powershell as a shell. Support 12
B IF command problem in tcexit.btm Support 9 Problem at Startup of TCC Support 3
P Problem with SFTP copies Support 7
P Problem with FTP copies Support 10
Jay Sage Problem with Context Menu Copy+Paste+Run Key Assignment Support 7
R Problem with %_do_loop in nested do loops Support 2

Similar threads