0

Good Day/Evening,

Maybe someone could help, and just maybe this could help someone else. If one observes the example below:

01022015- BLABLABLA 04022018 - BLABLABLAB 02012016 - Blablabla

What I would like to do is search for the 02 when its localed on the third and fourth character of the filename. Something like searching for "02" after the second character.

That way I would be able to sort out all Feb files separatedly, and then batch rename them properly.

Is this doable? Below na example of a search query that might serve as a basis for further development.

Thank you already ~"(4)"

3 Answers3

0

search for the 02 when its localed on the third and fourth character of the filename.

Use ? pattern symbol which means "1 char strongly":

DIR ??02*.*
Akina
  • 3,295
0

I think that you are lucky this time. The Regular Expression is quite simple in this case and it can be implemented even in the Microsoft Windows 10 Command-Line PreProcessor.

The Regular Expression is ??02*.

So you could boldly go and issue an Operating System Command such as the RENAME ??02* <New Name>.

RENAME Syntax

0

Try this for recursively:

for /f tokens^=* %F in ('where /r . "??02*.*"')do rename "%~F" "Some_New_Name%~xF"
  • Output:
rename "G:\SUPER_USER\Q59446122\310220218.txt" "Some_New_Name.txt"
rename "G:\SUPER_USER\Q59446122\110220218.txt" "Some_New_Name.txt"
rename "G:\SUPER_USER\Q59446122\100220218.txt" "Some_New_Name.txt"
rename "G:\SUPER_USER\Q59446122\Sub_1\170220218.txt" "Some_New_Name.txt"
rename "G:\SUPER_USER\Q59446122\Sub_1\030220218.txt" "Some_New_Name.txt"

Try this for current folder:

for /f tokens^=* %F in ('where "??02*.*"')do rename "%~F" 
  • Output:
rename G:\SUPER_USER\Q59446122\310220218.txt Some_New_Name.txt
rename G:\SUPER_USER\Q59446122\110220218.txt Some_New_Name.txt
rename G:\SUPER_USER\Q59446122\100220218.txt Some_New_Name.txt
Io-oI
  • 9,237