How can I organize my videos in folders according to year-month-day

Started by lamola, September 12, 2019, 11:13:11 AM

Previous topic - Next topic

lamola

Hello,

I want to organize my home video collection into directories according to the year-month-day (directory name = yyyy-mm-dd).
The videos are in avi and code dv format, or mp4 format and h264 format.
Is it possible to do it with exiftool? Or, do I need another program?

On the other hand, in my previous video editing program (Edius) I could superimpose the date and time on the edited videos but in my current video editor (Kdenlive) it is not possible (or maybe I don't know how to do it)

Thank you very much for your help.

StarGeek

Quote from: lamola on September 12, 2019, 11:13:11 AM
I want to organize my home video collection into directories according to the year-month-day (directory name = yyyy-mm-dd).
The videos are in avi and code dv format, or mp4 format and h264 format.
Is it possible to do it with exiftool? Or, do I need another program?

There are plenty of examples in the docs. Here's one on the Writing "FileName" and "Directory" tags page and another in the main docs under renaming examples.

The basic command for .MP4 files would be
exiftool -d "/path/to/new/directory/%Y-%m-%d" "-Directory<CreateDate" <FileOrDir>
Replace /path/to/new/directory/ with the correct path to where you want the file located.

With AVI files, they may not have embedded timestamps, as it's an older filetype.  You would first run
exiftool -time:all -a -s -ext AVI <File>
on one of the files to figure out if they have a timestamp you can use.  If you find one, you could then replace CreateDate in the above command with the name of that tag.  You would also have to add -ext AVI because exiftool doesn't normally process avi files by default (see FAQ #16).

QuoteOn the other hand, in my previous video editing program (Edius) I could superimpose the date and time on the edited videos but in my current video editor (Kdenlive) it is not possible (or maybe I don't know how to do it)

I'm not sure of your question here, but exiftool can't modify a video stream, so it can't do this.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

lamola

Thanks StarGeek,

I have executed the command you tell me and also another command changing -time: all to -all. These are the results:
C:\Users\KINGSTON>"C:\Archivos PORTABLES\Exiftool\exiftool.exe" -time:all -a -s -ext AVI "C:\Archivos PORTABLES\Exiftool\Cinta143.20140913-09-24-10.00.avi"
FileModifyDate                  : 2014:09:14 12:23:16+02:00
FileAccessDate                  : 2019:09:13 16:52:38+02:00
FileCreateDate                  : 2019:09:13 16:52:37+02:00


C:\Users\KINGSTON>"C:\Archivos PORTABLES\Exiftool\exiftool.exe" -all -a -s -ext AVI "C:\Archivos PORTABLES\Exiftool\Cinta143.20140913-09-24-10.00.avi"
ExifToolVersion                 : 11.50
FileName                        : Cinta143.20140913-09-24-10.00.avi
Directory                       : C:/Archivos PORTABLES/Exiftool
FileSize                        : 27 MB
FileModifyDate                  : 2014:09:14 12:23:16+02:00
FileAccessDate                  : 2019:09:13 16:52:38+02:00
FileCreateDate                  : 2019:09:13 16:52:37+02:00
FilePermissions                 : rw-rw-rw-
FileType                        : AVI
FileTypeExtension               : avi
MIMEType                        : video/x-msvideo
FrameRate                       : 25
MaxDataRate                     : 3891 kB/s
FrameCount                      : 185
StreamCount                     : 2
ImageWidth                      : 720
ImageHeight                     : 576
StreamType                      : Video
VideoCodec                      : dvsd
VideoFrameRate                  : 25
VideoFrameCount                 : 185
Quality                         : 0
SampleSize                      : Variable
BMPVersion                      : Windows V3
ImageWidth                      : 720
ImageHeight                     : 576
Planes                          : 1
BitDepth                        : 24
Compression                     : dvsd
ImageLength                     : 144000
PixelsPerMeterX                 : 0
PixelsPerMeterY                 : 0
NumColors                       : Use BitDepth
NumImportantColors              : All
StreamType                      : Audio
AudioCodec                      :
AudioSampleRate                 : 32000
AudioSampleCount                : 236800
Quality                         : 0
SampleSize                      : 4 bytes
Encoding                        : Microsoft PCM
NumChannels                     : 2
SampleRate                      : 32000
AvgBytesPerSec                  : 128000
BitsPerSample                   : 16
TotalFrameCount                 : 185
Duration                        : 7.40 s
ImageSize                       : 720x576
Megapixels                      : 0.415


The datetime does have it somewhere because with the Mediainfo program it informs about this data, as you can see in the output I transcribe.
PROGRAM MEDIAINFO
General
Complete name                            : C:\Archivos PORTABLES\Exiftool\Cinta143.20140913-09-24-10.00.avi
Format                                   : AVI
Format/Info                              : Audio Video Interleave
Commercial name                          : DVCAM
File size                                : 26.6 MiB
Duration                                 : 7 s 400 ms
Overall bit rate mode                    : Constant
Overall bit rate                         : 30.2 Mb/s
Recorded date                            : 2014-09-13 09:24:10.000

Video
ID                                       : 0
Format                                   : DV
Commercial name                          : DVCAM
Codec ID                                 : dvsd
Codec ID/Hint                            : Sony
Duration                                 : 7 s 400 ms
Bit rate mode                            : Constant
Bit rate                                 : 24.4 Mb/s
Width                                    : 720 pixels
Height                                   : 576 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Standard                                 : PAL
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Interlaced
Scan order                               : Bottom Field First
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 2.357
Time code of first frame                 : 00:03:05:20
Time code source                         : Subcode time code
Stream size                              : 25.4 MiB (96%)
Encoding settings                        : wb mode= / white balance= / fcm=auto focus

How will mediainfo get the information?

Thanks in advance


StarGeek

I did a slight edit on your post so I could read the data easier.

Hmmm...  It looks like Mediainfo is finding something that exiftool is not.  The time is off from the FileModifyDate by a day and 3 hours, so it's not using that, which is common thing for a lot of programs to read.

Unfortunately, I can't offer any advice in this case.  And Phil is currently away on vacation until late September.  If you're able to make a small sample available, through Google drive or Dropbox for example, he might want to take a look at it and see what's up.

I'd suggest hitting the "Notify" button in the upper right corner of this thread if you would like to get an email when there's a response to this thread.

Edit: Oops, wrong link to top of this thread, fixed.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

lamola

Thanks for everything, I will wait for Phil in case he has any solution to my problem.

greybeard


lamola

A sample.

LINK:  https://1drv.ms/f/s!Ak37_ejSsRf7pns939Hs0kwazLRt

StarGeek

This is definitely going to take some checking from Phil.  I did some poking around looking through the file and not sure where MediaInfo is pulling the data.  I found this list of supported tags on the MediaInfo website.  The "Recorded_Date" gives some details where it would take the data from, but there's nothing under RIFF, which would encompass AVI files.  Did some searching for the obvious plain text possibilities (2014 or DVCPRO) and nothing in the file in plain text.  FFProbe doesn't pull up any of the data the MediaInfo does.

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Hayo Baan

Interesting! I analysed both files you uploaded and I really can't see where the dates as reported by Mediainfo are coming from. The date tags in the mov file for instance are actually all 0 and if there are date tags in the avi file, then exiftool is currently unable to find them. Still, for both files Mediainfo reports recording dates so they must be present somewhere in the files, but not at a "standard" location. Perhaps Phil is able to determine where they are coming from?
Hayo Baan – Photography
Web: www.hayobaan.nl

greybeard

For the avi file the recorded date is in the LIST_movi chunk that Exiftool doesn't appear to parse.

If you run exiftool with the -v2 switch you will seem the chunk listed but the date/time fields haven't been extracted.


StarGeek

Please be patient.  Phil is probably still on vacation.  He might be back tomorrow or the next day.  The last patch notes said his vacation is through the 24th. 
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

greybeard

My guess is that this will be non-trivial (even for Phil)

Why not just use mediainfo?

Here is an example that generates a series of move commands for each of the AVI files. You would save the commands in a file and run as a batch.
It has the advantage that you can read the batch file and make sure it does it exactly what you want before you run it.
(the exact syntax will depend on your operating system and command shell):

a) Create directory structure:
mediainfo --Inform="General;mkdir %Recorded_Date%" *.avi | sed -e 's/ [0-9][0-9]:[0-9][0-9]:[0-9][0-9].000//g'

b) Move files
mediainfo --Inform="General;mv %FileName%.avi %Recorded_Date%/%FileName%.avi" *.avi | sed -e 's/ [0-9][0-9]:[0-9][0-9]:[0-9][0-9].000//g'

(The "sed" part of the command is being used to remove the time part of the Recorded date - if you don't have sed then something else would be needed)

lamola

Thank you for your attention but with what S.O. Are the commands written?
My S.O. it's windows 10.
lamola

greybeard

Those were Linux (or a Linux-like shell under Windows)

I just tested these under the Windows Powershell

mediainfo --Inform="General;mkdir %Recorded_Date%\r\n" *.avi  | %{$_ -replace " \d\d:\d\d:\d\d.000",""}
mediainfo --Inform="General;mv %FileName%.avi %Recorded_Date%/%FileName%.avi\r\n" *.avi  | %{$_ -replace " \d\d:\d\d:\d\d.000",""}