Windows 10 - Searching for a specific part of a filename within a set interval of characters

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)"

LLVZahyin

Posted 2019-09-23T13:41:36.127

Reputation: 1

Answers

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

Posted 2019-09-23T13:41:36.127

Reputation: 2 991

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

user1018743

Posted 2019-09-23T13:41:36.127

Reputation:

0

Try this for recursively:

for /f tokens^=* %F in ('where /r . "??02*.*"')do @echo/rename "%~F" "Some_New_Name%~xF"
  • Output:
rename "G:\SUPER_USER\Q59446122\31022018.txt" "Some_New_Name.txt"
rename "G:\SUPER_USER\Q59446122\11022018.txt" "Some_New_Name.txt"
rename "G:\SUPER_USER\Q59446122\10022018.txt" "Some_New_Name.txt"
rename "G:\SUPER_USER\Q59446122\Sub_1\17022018.txt" "Some_New_Name.txt"
rename "G:\SUPER_USER\Q59446122\Sub_1\03022018.txt" "Some_New_Name.txt"

Try this for current folder:

for /f tokens^=* %F in ('where "??02*.*"')do @echo/rename "%~F" 
  • Output:
rename G:\SUPER_USER\Q59446122\31022018.txt Some_New_Name.txt
rename G:\SUPER_USER\Q59446122\11022018.txt Some_New_Name.txt
rename G:\SUPER_USER\Q59446122\10022018.txt Some_New_Name.txt

It Wasn't Me

Posted 2019-09-23T13:41:36.127

Reputation: 851