How to add characters at certain spaces in filenames?

Post any Bulk Rename Utility support requirements here. Open to all registered users.

How to add characters at certain spaces in filenames?

Postby Yotry8 » Sat Jul 29, 2023 11:38 am

Hi, i'm not savvy with regex or anything like that but I need some help

What I'm trying to do is change the filenames on a bunch of ps4/ps5 screenshots to make the date and time more easy to read

The default filename format is gamename_yearmonthdayhoursminuteseconds

Here's an example, Enter the Gungeon_20210329072503

I want to add some hyphens or periods to make it clearer to read, something like Enter the Gungeon_2021-03-29.07.25.03

So I guess what I need is a command or regex or whatever to add a period two spaces from the end, then another two spaces from there, then another two spaces from there, then a hyphen two spaces from there, then another hyphen after two spaces etc., you know what I mean

As a bonus, Does anyone how I could bulk change the date modified on the files to the date in the filenames?

Thanks for any assistance!
Yotry8
 
Posts: 2
Joined: Sat Jul 29, 2023 11:26 am

Regex to edit date at end of filename

Postby Luuk » Sun Jul 30, 2023 3:36 am

Its unfortunate, but "Change Filestamps" inside of Special(14) cannot look at the filename characters.
So for myself, I'm probably just use the free exiftool.exe to conduct my renames with the timestamps.

But for only renaming, can use RegEx(1) with a "Match" and "Replace" something like...
(.+_20\d\d)(0[1-9]|1[012])(0[1-9]|[1-3]\d)([01]\d|2[0-4])([0-5]\d)([0-5]\d)$
\1-\2-\3.\4.\5.\6


To let the exiftool.exe conduct renames and change $DateModified, its command is like...
Code: Select all
C:\Path\To\exiftool.exe -r -m -fast4 -overwrite_original -if "$filename=~/.+_20\d\d(0[1-9]|1[012])(0[1-9]|[1-3]\d)([01]\d|2[0-4])[0-5]\d[0-5]\d\.[^.]+$$/" -FileModifyDate"<${filename; s/.*_(....)(..)(..)(..)(..)(..)\.[^.]+$/$1:$2:$3 $4:$5:$6/}" -Filename"<${filename; s/(.+_.{4})(..)(..)(..)(..)(..\.[^.]+)$/$1-$2-$3.$4.$5.$6/}" "C:/Path/To/YourFolder"

If you already renamed with BRU, then exiftool could edit $DateModified like...
Code: Select all
C:\Path\To\exiftool.exe -r -m -fast4 -overwrite_original -if "$filename =~ /.+_20\d\d-(0[1-9]|1[012])-(0[1-9]|[1-3]\d)\.([01]\d|2[0-4])\.[0-5]\d\.[0-5]\d\.[^.]+$$/" -FileModifyDate"<${filename; s/.*_(.{4})-(..)-(..).(..).(..).(..)\.[^.]+$/$1:$2:$3 $4:$5:$6/}" "C:/Path/To/YourFolder"
Luuk
 
Posts: 705
Joined: Fri Feb 21, 2020 10:58 pm

Re: Regex to edit date at end of filename

Postby Yotry8 » Thu Oct 19, 2023 7:53 am

Luuk wrote:Its unfortunate, but "Change Filestamps" inside of Special(14) cannot look at the filename characters.
So for myself, I'm probably just use the free exiftool.exe to conduct my renames with the timestamps.

But for only renaming, can use RegEx(1) with a "Match" and "Replace" something like...
(.+_20\d\d)(0[1-9]|1[012])(0[1-9]|[1-3]\d)([01]\d|2[0-4])([0-5]\d)([0-5]\d)$
\1-\2-\3.\4.\5.\6


To let the exiftool.exe conduct renames and change $DateModified, its command is like...
Code: Select all
C:\Path\To\exiftool.exe -r -m -fast4 -overwrite_original -if "$filename=~/.+_20\d\d(0[1-9]|1[012])(0[1-9]|[1-3]\d)([01]\d|2[0-4])[0-5]\d[0-5]\d\.[^.]+$$/" -FileModifyDate"<${filename; s/.*_(....)(..)(..)(..)(..)(..)\.[^.]+$/$1:$2:$3 $4:$5:$6/}" -Filename"<${filename; s/(.+_.{4})(..)(..)(..)(..)(..\.[^.]+)$/$1-$2-$3.$4.$5.$6/}" "C:/Path/To/YourFolder"

If you already renamed with BRU, then exiftool could edit $DateModified like...
Code: Select all
C:\Path\To\exiftool.exe -r -m -fast4 -overwrite_original -if "$filename =~ /.+_20\d\d-(0[1-9]|1[012])-(0[1-9]|[1-3]\d)\.([01]\d|2[0-4])\.[0-5]\d\.[0-5]\d\.[^.]+$$/" -FileModifyDate"<${filename; s/.*_(.{4})-(..)-(..).(..).(..).(..)\.[^.]+$/$1:$2:$3 $4:$5:$6/}" "C:/Path/To/YourFolder"


Thank you! This worked perfectly!
Yotry8
 
Posts: 2
Joined: Sat Jul 29, 2023 11:26 am


Return to BRU Support


cron