Regex problem: \xnn not recognized as a hex character

rps

Jul 6, 2008
426
5
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
#13

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:
Code:
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:

Code:

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:
Code:
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].