Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

REN implied .*

samintz

Scott Mintz
May
1,590
27
In the following code I did not specify an extension in the REN command, but it still did the rename as if there was an implied ".*" added to end.
Code:
[C:\TC22]
$ >SmithAdj20180530.txt

[C:\TC22]
$ >SmithRcpt20180530.txt

[C:\TC22]
$ ren "::(Smith)(Adj|Rcpt)(\d\d\d\d)(\d\d)(\d\d)" ::\1_\2-\3-\4-\5
C:\TC22\SmithAdj20180530.txt -> C:\TC22\Smith_Adj-2018-05-30.txt
C:\TC22\SmithRcpt20180530.txt -> C:\TC22\Smith_Rcpt-2018-05-30.txt
     2 files renamed

Is this WAD?
 
As I understand it, your regex means that the filename must contain the stuff you specify. To limit it only filenames containing only the stuff you specify, you'd use /A (at the start) or /Z or /z (at the end).

Code:
ren /n "::(Smith)(Adj|Rcpt)(\d\d\d\d)(\d\d)(\d\d)\Z" ::\1_\2-\3-\4-\5
 
Yeah, but in the case of REN someone is going out of their way to preserve text before and after the regex (as if REN is using @REGEX to find the file and @REREPLACE to rename it) ... all of which is OK with me. But there's a point of view from which the behavior is surprising.
 
Back
Top
[FOX] Ultimate Translator
Translate