Adjust Photo Time in File Name

A swapping-ground for Regular Expression syntax

Adjust Photo Time in File Name

Postby rwallace » Wed Jun 16, 2021 5:47 pm

I have a bunch of photos that are named in the following way:
2021-06-1413_21_58.050377

Where the format is:
YYYY-mm-ddHH_MM_SS.SSSSSS

The issue I have is that the files have incorrectly been coded with the wrong time, and I need to reduce the hours (in 24hr format) by 5 hours. This would mean that the final file name should be:
2021-06-1408_21_58.050377

I am hoping this can be done relatively easily with a Regular Expression, but this is the first time I have ever used that method.

Thanks
Ryan
rwallace
 
Posts: 2
Joined: Wed Jun 16, 2021 5:28 pm

Re: Adjust Photo Time in File Name

Postby Luuk » Wed Jun 16, 2021 10:52 pm

The javascript conducts this very easy, but its for the paid version, and another section in the forum.
It would take very many hours to write enough regular expressions to properly conduct decreasing the dates.
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm

Re: Adjust Photo Time in File Name

Postby rwallace » Thu Jun 17, 2021 2:20 pm

Luuk wrote:The javascript conducts this very easy, but its for the paid version, and another section in the forum.
It would take very many hours to write enough regular expressions to properly conduct decreasing the dates.


I thought the software was completely free for personal use? Are there other features that are not available? I see the Javascript Renaming available in the Special menu selection.

Thanks
Ryan
rwallace
 
Posts: 2
Joined: Wed Jun 16, 2021 5:28 pm

Re: Adjust Photo Time in File Name

Postby Luuk » Thu Jun 17, 2021 6:48 pm

Greetings Ryan. All of the other features are free, but its just javascript that needs the paid version to conduct renames.
The free users can still experiment with the javascript, but its just for presenting previews under the "New Name" column.
So you could still type something like this into the javascript window...

if (/^\d{4}-\d\d-\d{4}_\d\d_\d\d\.\d+/.test(name)) {
x = new Date(Date.parse(name.replace(/^(\d{4})-(\d\d)-(\d\d)(\d\d).*/, '$1,$2,$3,$4')));
function decrease() {x.setHours(x.getHours()-5); return x};
y = decrease(x);
month = ('0'+(y.getMonth()+1)).replace(/^0(\d\d)$/,'$1');
day = ('0'+(y.getDate())).replace(/^0(\d\d)$/,'$1');
hr = ('0'+(y.getHours())).replace(/^0(\d\d)$/,'$1');
newName = y.getFullYear()+'-'+month+'-'+day+hr+name.substr(12) }

And it presents how decreasing the hours by 5, could also modify the dates like...
2021-01-0101_21_58.050377-text.jpg ====> 2020-12-3120_21_58.050377-text.jpg
2021-06-1413_21_58.050377-text.jpg ====> 2021-06-1408_21_58.050377-text.jpg
2021-06-1423_21_58.050377-text.jpg ====> 2021-06-1418_21_58.050377-text.jpg

But then clicking "Rename" would not conduct the renames, without having the paid version ahead of time.
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm


Return to Regular Expressions