Page 1 of 1

How to add characters at certain spaces in filenames?

PostPosted: Sat Jul 29, 2023 11:38 am
by Yotry8
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!

Regex to edit date at end of filename

PostPosted: Sun Jul 30, 2023 3:36 am
by Luuk
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"

Re: Regex to edit date at end of filename

PostPosted: Thu Oct 19, 2023 7:53 am
by Yotry8
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!