Video files renaming -> pls help @ Luuk

Bulk Rename Utility How-To's

Video files renaming -> pls help @ Luuk

Postby lilimo » Tue Jun 21, 2022 12:43 pm

Hi Luuk,

I am hoping you can come across this thread. You previously helped me with my whatsapp picture renaming and I still was hoping you could help me with the below...

They are structured in the same way. Could you help me with this? To also change the exif information and rename the files? Only issue is I have already converted the pictures, so perhaps the ending of the file could be a slightly different? Otherwise when I throw into DCIM folder in my android they might clash?
If this is complicated, I have also maintaned an original folder before conversion just in case. So I can just follow your instructions as to whatever is most convenient.

I have tried to use the command below, and replaced jpg/jpeg with mp4 but didn't have any luck....

C:\Users\ricar\exiftool -m -r -ext jpg -ext jpeg -overwrite_original -Progress:"ExifTool %p%%" -if "not $AllDates and $filepath=~/\/2013(0[89]|1[012])|201[4-8](0[1-9]|1[012])|20190[1-5]\//" -testname"<C:/Users/ricar/exif-finished/${filepath;s/.*\/(\d{6})\/.*/$1/}%-.3nc.%e" "C:/Users/ricar/Downloads/Whatsapp files/201???" >C:\Users\ricar\Desktop\exif-test-names.txt

Please see my path for the videos...
C:\Users\ricar\Downloads\whatsapp videos\201308\Media\85xxxxxxx70@s.whatsapp.net\1\4
C:\Users\ricar\Downloads\whatsapp videos\201712\Media\85xxxxxxx27-1508132553@g.us\f\9

You get the idea...

Thank you again!!
lilimo
 
Posts: 12
Joined: Sat Feb 12, 2022 9:11 am

Video renaming and writing dates from folder-path

Postby Luuk » Mon Jun 27, 2022 9:37 am

====================== Pictures (jpg, jpeg) ======================
Its unfortunate, but the command-line now being posting cannot write to the exif-dates, because its missing the -AllDates parameter.
If you did only change -testname ===> -filename, then it would only conduct the renames, but not write to any of the exif-dates!
Im hoping that you did probably just post the wrong command-line, so that your pictures can already have the correct dates?
viewtopic.php?f=12&t=5793#p15911

So before conducting any videos, please to use the below command to compare each picture's exif-date to its new filename.
Code: Select all
C:\Users\ricar\exiftool -s -m -r -ext jpg -ext jpeg  -progress:"ExifTool %p%%" -if "$filename=~/201\d{3}-\d{3}\.jpe?g$$/  and (${AllDates;s/^(\d{4}):(\d\d).*/$1$2/} ne ${filename;s/^(.{6}).*/$1/})" -p "$filename" "C:/Users/ricar/exif-finished"

If any filenames present, its because the month/year in their exif-date is different from the month/year in their filename.
So to rewrite these exif-dates by looking at the filenames instead of folder-paths, you can now just change...
-s ===> -overwrite_original and -p "$filename" ===> -AllDates"<${filename;s/^(\d{4})(\d{2}).*/$1:$2:01 00:00:00/}"

You could run the 1st-command again, just to verify that all of the exif-dates have the same month and year that is inside of their filenames.
After you verified the pictures all have correct exif-dates, but worry for duplicate filenames in DCIM (because you conducted them too)??
I would just use the bru to append something like --fixed, or whatever the difference is between your 'DCIM' and 'exif-finished' folders?


====================== Videos (3gp, mp4) ===========================
Its unfortunate, but not $AllDates will succeed with videos, because their unknown-dates often get written like 0000:00:00 00:00:00 !!
Videos do also have much more metadata for their dates, so you will need more -TagNames to conduct the same, like with your jpegs.
Also, if any videos can be larger than 4GB, then must add -api LargeFileSupport, but this does makes conducting videos much slower!

To compare all video-dates to their folder-path, from /whatsapp videos/201308-->201905/, its a much longer command like...
Code: Select all
C:\Users\ricar\exiftool -m -r -ext mp4 -ext 3gp -api QuickTimeUTC -progress:"ExifTool %p%%" -if "($Filepath=~/\/2013(0[89]|1[012])|201[4-8](0[1-9]|1[012])|20190[1-5]\//) and ((${AllDates;s/^(\d{4}):(\d\d).*/$1$2/} eq ${filepath;s/.*\/(201\d{3})\/.*/$1/}) or (${MediaCreateDate;s/^(\d{4}):(\d\d).*/$1$2/} eq ${filepath;s/.*\/(201\d{3})\/.*/$1/}) or (${MediaModifyDate;s/^(\d{4}):(\d\d).*/$1$2/} eq ${filepath;s/.*\/(201\d{3})\/.*/$1/}) or (${TrackCreateDate;s/^(\d{4}):(\d\d).*/$1$2/} eq ${filepath;s/.*\/(201\d{3})\/.*/$1/}) or (${TrackModifyDate;s/^(\d{4}):(\d\d).*/$1$2/} eq ${filepath;s/.*\/(201\d{3})\/.*/$1/}))"  -p  "$filepath"  "C:/Users/ricar/Downloads/whatsapp videos"
I did make this the opposite of the last time with jpegs, so now there is not needed to look inside of any preview-file.
Its only presenting file/path/names, when it finds any video-date that matches the same year and month inside of the folder-path.
The $AllDates will look many more places inside of videos, but not in Media*Dates and Track*Dates, so they are added for the search.

If any of your dates has a correct yyyymm, then you can use it to set the other dates, so then saving the correct day and times also.
But if no filepaths are presented, this would mean that all of your dates have the wrong yyyy:mm (if the folders are to be correct).
And you would have to conduct the videos like your jpegs, using the folders and guessing 01 00:00:00 for the day and time.

IF you did already verify that all of the dates are bad, this to conduct like the jpegs...
Code: Select all
C:\Users\ricar\exiftool -m -r -overwrite_original -ext mp4 -ext 3gp -api QuickTimeUTC -progress:"ExifTool %p%%" -if "($Filepath=~/\/2013(0[89]|1[012])|201[4-8](0[1-9]|1[012])|20190[1-5]\//) and (${AllDates;s/^(\d{4}):(\d\d).*/$1$2/} ne ${filepath;s/.*\/(201\d{3})\/.*/$1/}) and (${MediaCreateDate;s/^(\d{4}):(\d\d).*/$1$2/} ne ${filepath;s/.*\/(201\d{3})\/.*/$1/}) and (${MediaModifyDate;s/^(\d{4}):(\d\d).*/$1$2/} ne ${filepath;s/.*\/(201\d{3})\/.*/$1/}) and (${TrackCreateDate;s/^(\d{4}):(\d\d).*/$1$2/} ne ${filepath;s/.*\/(201\d{3})\/.*/$1/}) and (${TrackModifyDate;s/^(\d{4}):(\d\d).*/$1$2/} ne ${filepath;s/.*\/(201\d{3})\/.*/$1/})"  -AllDates"<${Filepath;s/.*\/(201\d)(\d{2})\/.*/$1:$2:01 00:00:00/}" -Media*Date"<${Filepath;s/.*\/(201\d)(\d{2})\/.*/$1:$2:01 00:00:00/}" -Track*Date"<${Filepath;s/.*\/(201\d)(\d{2})\/.*/$1:$2:01 00:00:00/}"  -Filename"<C:/Users/ricar/exif-finished/${filepath;s/.*\/(201\d{3})\/.*/$1/}%-.3nc.%e"  "C:/Users/ricar/Downloads/whatsapp videos/201???"

After writing to the dates, it does then rename and move the files like...
C:\Users\ricar\Downloads\whatsapp videos\201510\Media\Phone#\8\e\aaa.mp4 ====> C:\Users\ricar\exif-finished\201510-001.mp4
C:\Users\ricar\Downloads\whatsapp videos\201510\Media\Phone#\7\f\bbb.mp4 ====> C:\Users\ricar\exif-finished\201510-002.mp4
C:\Users\ricar\Downloads\whatsapp videos\201803\Media\Phone#\d\1\aaa.mp4 ====> C:\Users\ricar\exif-finished\201803-001.mp4
C:\Users\ricar\Downloads\whatsapp videos\201803\Media\Phone#\8\2\bbb.mp4 ====> C:\Users\ricar\exif-finished\201803-002.mp4
C:\Users\ricar\Downloads\whatsapp videos\201803\Media\Phone#\2\e\aaa.mp4 ====> C:\Users\ricar\exif-finished\201803-003.mp4
C:\Users\ricar\Downloads\whatsapp videos\201908\Media\Phone#\2\e\aaa.mp4 ====> (no changes, because 201908 is out of range)

Remember it only looks beneath /whatsapp videos/201308-->201905/, and it only conducts videos if all of their dates dont match the folder-path.
Must also add -api LargeFileSupport if videos can be >4GB, and just change exif-finished to wherever you really want to settle your videos.
If you like to add some -suffix, you can change it like .3nc.%e ===> .3nc-suffix.%e (inbetween the "c" and "." or just use the bru later).
Many apologies for not seeing the post, its good you make another one!
Luuk
 
Posts: 488
Joined: Fri Feb 21, 2020 10:58 pm

Re: Video files renaming -> pls help @ Luuk

Postby lilimo » Mon Jun 27, 2022 3:06 pm

Thank you for getting back to me!

The pictures renamed fine I think, so thank you for that!

Regarding the videos, I ran your last command but only part of the files were copied and renamed, I can't explain why.

1112 directories scanned
242 files failed condition
0 image files read

THanks again in advance for your help
lilimo
 
Posts: 12
Joined: Sat Feb 12, 2022 9:11 am

Video renaming and writing dates from folder-path

Postby Luuk » Mon Jun 27, 2022 7:49 pm

Its because either their folder-name is out-of-range, or because there is at least one-good-date inside of the video, unless you have more file-extensions?
The first command would have presented videos with a good yyyy:mm, so then we could use the good-date to fix the other-dates, saving both the dd:time.
The videos that got written and moved were the ones with a bad yyyy:mm, so exiftool just used the folder-path for yyyy:mm, and guessed the dd:time.

To create a preview-file for unmoved videos that already had at least one good-date, can use a command like...
Code: Select all
C:\Users\ricar\exiftool -m -r -s -ext mp4 -ext 3gp -api QuickTimeUTC -progress:"ExifTool %p%%" -if "($Filepath=~/\/2013(0[89]|1[012])|201[4-8](0[1-9]|1[012])|20190[1-5]\//) and ((${AllDates;s/^(\d{4}):(\d\d).*/$1$2/} eq ${filepath;s/.*\/(201\d{3})\/.*/$1/}) or (${MediaCreateDate;s/^(\d{4}):(\d\d).*/$1$2/} eq ${filepath;s/.*\/(201\d{3})\/.*/$1/}) or (${MediaModifyDate;s/^(\d{4}):(\d\d).*/$1$2/} eq ${filepath;s/.*\/(201\d{3})\/.*/$1/}) or (${TrackCreateDate;s/^(\d{4}):(\d\d).*/$1$2/} eq ${filepath;s/.*\/(201\d{3})\/.*/$1/}) or (${TrackModifyDate;s/^(\d{4}):(\d\d).*/$1$2/} eq ${filepath;s/.*\/(201\d{3})\/.*/$1/}))"   -AllDates -Media*Date -Track*Date    "C:/Users/ricar/Downloads/whatsapp videos" >C:/Users/ricar/desktop/VideosWithAtLeast1GoodDate.txt


For all videos below folder-names ranging from 201308-201905, and having at least 1 matching good-date, something like this to be inside of the preview-file...
======== C:/Users/ricar/Downloads/whatsapp videos/201312/Media/85xxxxxxx70@s.whatsapp.net/1/4/Some-Name.mp4
DateTimeOriginal ..: 2001:02:01 12:00:00
CreateDate .........: 2001:02:01 15:00:00
ModifyDate .........: 0000:00:00 00:00:00
MediaCreateDate ..: 2013:12:25 00:00:00-08:00
MediaModifyDate ..: 0000:00:00 00:00:00
MediaEventIdDate .: 0000:00:00 00:00:00
TrackCreateDate ...: 0000:00:00 00:00:00
TrackModifyDate ...: 0000:00:00 00:00:00
======== C:/Users/ricar/Downloads/whatsapp videos/201304/Media/85xxxxxxx27-1508132553@g.us/f/9/Some-Name.mp4
DateTimeOriginal ..: 2001:02:01 12:00:00
CreateDate .........: 2001:02:01 15:00:00
ModifyDate .........: 0000:00:00 00:00:00
MediaCreateDate ..: 2013:04:12 00:00:00-08:00
MediaModifyDate ..: 0000:00:00 00:00:00
MediaEventIdDate .: 0000:00:00 00:00:00
TrackCreateDate ...: 0000:00:00 00:00:00
TrackModifyDate ...: 0000:00:00 00:00:00

So what you are looking for is the matching-dates, so then you can see which TagNames on the left do already have a correct-date..
You are hoping to find at least one TagName, like MediaCreateDate that does always have a good-date, but if its only a few, thats ok also.
So depending on which TagNames are good, I can advise on how to set all of the other dates first, before renaming, moving, and overwriting the good-dates.

Except of course, nothing is colored for you, so Im just using something like the Notepad++ to edit the preview-files first. This can make the preview-file much smaller and easier to use, if needing help to edit, just let me know.. First thing I would do is put a dot in "Regular expression", then put ^.*: 0+:0+:0+ 0+:0+:0+[\r\n]+ in for the "Find what". Then with nothing for "Replace with" just click "Replace, Replace All" to delete the lines with 0000:00:00 00:00:00
Luuk
 
Posts: 488
Joined: Fri Feb 21, 2020 10:58 pm

Re: Video files renaming -> pls help @ Luuk

Postby lilimo » Tue Jun 28, 2022 1:01 pm

Thank you again for your reply.

I must admit at this point it is a bit complicated for me.
I ran your command prompt:

1113 directories scanned
242 image files read

I have checked in the folder via search with *.mp4 and I do find 242 files, so it is correct. I've also looked at the text and the media create date does seem to match the folder date names.

======== C:/Users/ricar/Downloads/whatsapp videos/201411/Media/853xxxxxxxx1382016236@g.us/2/0/206297d70586c1de064809be9e47d894.mp4
CreateDate : 2014:11:22 12:39:27+08:00
ModifyDate : 2014:11:22 12:39:58+08:00
MediaCreateDate : 2014:11:22 12:39:27+08:00
MediaModifyDate : 2014:11:22 12:39:58+08:00
TrackCreateDate : 2014:11:22 12:39:27+08:00
TrackModifyDate : 2014:11:22 12:39:58+08:00

======== C:/Users/ricar/Downloads/whatsapp videos/201905/Media/351xxxxxxxxx@s.whatsapp.net/d/c/dc58ab0d-9e13-471b-b798-2183d85dae42.mp4
CreateDate : 2019:05:06 15:57:41+08:00
ModifyDate : 2019:05:06 15:57:42+08:00
MediaCreateDate : 2019:05:06 15:57:41+08:00
MediaModifyDate : 2019:05:06 15:57:42+08:00
TrackCreateDate : 2019:05:06 15:57:41+08:00
TrackModifyDate : 2019:05:06 15:57:42+08:00

From here what do I do?
What would be the correct prompt to rewrite these?

Thank you again!
lilimo
 
Posts: 12
Joined: Sat Feb 12, 2022 9:11 am

Video renaming and writing dates

Postby Luuk » Wed Jun 29, 2022 12:54 am

Since it does look like the remaining 242 videos have all correct-dates?, I would not overwrite any of their dates.
Often a video has only a few good-dates, so users will let exiftool choose a good-date, to write all of the bad-ones.
But with the example now being posting, Im guessing that maybe all of your remaining dates is correct?

If it does really matter to you?, and you have any bad-dates?, then we can just fix the bad-dates before renaming and moving.
With Notepad++ a regex-search like ^(=+.+videos/(\d{4})(\d\d)/[^=]+\2:\3.*[\r\n]*)+ highlights the good-parts in the preview-file.
If it selects the whole file, then every one of the dates in all 242 videos, is already good.

So just to let me know if you have any bad-dates, like 0000:00:00 00:00:00 that should probably be written to?
For renaming and moving, do you follow the same format now, like yyyymm-### or maybe now want yyyymmdd-### ?
If staying with yyyymm-###, the exiftool resumes numbering after the last-used yyyymm-### in the destination.

If its me, Im probably just stay with yyyymm-### for now for the numbering, but its very easy changing any of this later.
The main thing is not to overwrite the good-dates, so you can use them later for renaming, moving, etc.
Luuk
 
Posts: 488
Joined: Fri Feb 21, 2020 10:58 pm

Re: Video files renaming -> pls help @ Luuk

Postby lilimo » Fri Jul 01, 2022 12:12 pm

Hi again,

Apologies, I don't know how to use notepad++, this is already out of my depth. But given that all the videos are from the same source. I would imagine they if a the ones I showed you are correct, then the rest is too...

We can keep the basic format you suggested?

Would you mind sharing the scriptso I can directly do the renaming?

Thank you
lilimo
 
Posts: 12
Joined: Sat Feb 12, 2022 9:11 am

Video renaming from folder-path

Postby Luuk » Fri Jul 01, 2022 7:08 pm

If you post the preview-file somewhere, I can review the file in less than a minute, to confirm all of their dates.
Im was going to provide a script to fix any bad-dates, then rename and move, but it would rely on dependable dates.
So there is no way I can advise that script, without first looking at the preview-file.

I can provide a script to just rename and move, by looking at the folder-path, since 'dd' will not be in the filenames.
We already confirmed that all 242 videos, have at least 1 good-date with a 'yyyymm' that matches its /yyyymm/ in the folder-path.
But this renaming script will not fix any of the bad dates, so you would have to fix them at some other time, with much more effort.

This one will only conduct the renaming and moving, and only when there is at least one good-date, like inside of the preview-file.
It will not overwrite any bad-dates, and numbering will only resume if using the same destination as your other videos, that had all bad-dates.
This one uses the destination /exif-finished/, so if you did change the last one or moved them to another destination, you must change this one also...
Code: Select all
C:\Users\ricar\exiftool -m -r -ext mp4 -ext 3gp -overwrite_original -api QuickTimeUTC -progress:"ExifTool %p%%" -if "($Filepath=~/\/2013(0[89]|1[012])|201[4-8](0[1-9]|1[012])|20190[1-5]\//) and ((${AllDates;s/^(\d{4}):(\d\d).*/$1$2/} eq ${filepath;s/.*\/(201\d{3})\/.*/$1/}) or (${MediaCreateDate;s/^(\d{4}):(\d\d).*/$1$2/} eq ${filepath;s/.*\/(201\d{3})\/.*/$1/}) or (${MediaModifyDate;s/^(\d{4}):(\d\d).*/$1$2/} eq ${filepath;s/.*\/(201\d{3})\/.*/$1/}) or (${TrackCreateDate;s/^(\d{4}):(\d\d).*/$1$2/} eq ${filepath;s/.*\/(201\d{3})\/.*/$1/}) or (${TrackModifyDate;s/^(\d{4}):(\d\d).*/$1$2/} eq ${filepath;s/.*\/(201\d{3})\/.*/$1/}))"  -Filename"<C:/Users/ricar/exif-finished/${filepath;s/.*\/(201\d{3})\/.*/$1/}%-.3nc.%e"  "C:/Users/ricar/Downloads/whatsapp videos/201???"

Do not add any suffix, unless you have already suffixed the others, so that numbering will resume.
Also, must add -api LargeFileSupport to conduct any videos that might be larger than 4GB.
Luuk
 
Posts: 488
Joined: Fri Feb 21, 2020 10:58 pm


Return to How-To