Skip to main content
Participant
May 26, 2021
Question

Batch Rename using Regular Expression

  • May 26, 2021
  • 2 replies
  • 377 views

My stupid phone sometimes names photos 20200226_150253.jpg and then other times names them 2020-02-27 178241.jpg. I swear I haven't mess with any photo settings on my phone. So, when  I upload images to a single 2020 Photo folder, the images don't arrange in chronological order.

Can someone provide me with a Regular Expression to select 20200226_  --selecting all XX(month) and all XX(day) and replace with the same MM/DD, in the format 2020-02-27  --so that I can fix all of them in one single batch rename? 

Thanks so much!

This topic has been closed for replies.

2 replies

Stephen Marsh
Community Expert
Community Expert
May 27, 2021

 

First regex (original filename):

 

Find:

[-| |_]

 

Replace:

(blank, nothing)

 

Second regex (intermediate filename):

 

Find:

(\d{8})(\d+)

 

Replace:

$1-$2

 

 

The result:

 

 

Stephen Marsh
Community Expert
Community Expert
May 27, 2021

Hmmm, I'm not sure if I read/understood the request correctly the first time!

 

Second regex (intermediate filename):

 

Find:

(\d{4})(\d{2})(\d{2})(\d{6})

 

or

 

(\d{4})(\d{2})(\d{2})(\d+)

 

Replace:

$1-$2-$3_$4

 

Final result:

2020-02-26_150253.png
2020-02-27_178241.png

gregreser
Legend
May 26, 2021

I think this will work

 

Find: ^(.{4})(.{2})

Replace: $1-$2-