ExifTool Forum

ExifTool => Newbies => Topic started by: lamola on September 12, 2019, 11:13:11 AM

Title: How can I organize my videos in folders according to year-month-day
Post by: lamola on September 12, 2019, 11:13:11 AM
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.
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: StarGeek on September 12, 2019, 11:48:06 AM
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 (https://exiftool.org/filename.html#ex2) on the Writing "FileName" and "Directory" tags page and another (https://exiftool.org/filename.html#ex2) 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 (https://exiftool.org/faq.html#Q16)).

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.
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: lamola on September 13, 2019, 11:13:14 AM
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

Title: Re: How can I organize my videos in folders according to year-month-day
Post by: StarGeek on September 13, 2019, 12:15:40 PM
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 (https://exiftool.org/forum/index.php/topic,10450.msg55111.html#main_content_section) 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.
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: lamola on September 16, 2019, 02:52:08 AM
Thanks for everything, I will wait for Phil in case he has any solution to my problem.
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: greybeard on September 16, 2019, 04:54:33 AM
As StarGeek says - a small sample would be most helpful
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: lamola on September 18, 2019, 01:46:52 AM
A sample.

LINK:  https://1drv.ms/f/s!Ak37_ejSsRf7pns939Hs0kwazLRt
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: StarGeek on September 18, 2019, 02:56:24 AM
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 (https://mediaarea.net/en/MediaInfo/Support/Tags) 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.

Title: Re: How can I organize my videos in folders according to year-month-day
Post by: Hayo Baan on September 18, 2019, 05:20:49 AM
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?
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: greybeard on September 18, 2019, 10:47:09 AM
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.
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: lamola on September 23, 2019, 04:36:27 PM
Phil, can you help me? please
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: StarGeek on September 23, 2019, 06:10:21 PM
Please be patient.  Phil is probably still on vacation.  He might be back tomorrow or the next day.  The last patch notes (https://github.com/exiftool/exiftool/blob/master/Changes#L10) said his vacation is through the 24th. 
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: greybeard on September 24, 2019, 04:12:13 AM
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)
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: lamola on September 24, 2019, 10:11:22 AM
Thank you for your attention but with what S.O. Are the commands written?
My S.O. it's windows 10.
lamola
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: greybeard on September 24, 2019, 11:03:16 AM
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",""}
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: greybeard on September 25, 2019, 07:05:20 AM
Quote from: greybeard on September 24, 2019, 11:03:16 AM
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",""}

A couple of corrections as I don't really understand much about Windows

When I first ran these commands in the Powershell they outputted a double-byte character set.

I ended up running the following before the commands:

$PSDefaultParameterValues = @{ '*:Encoding' = 'utf8' }

Also the Linux "mv" command above doesn't seem to work for Windows - it should be "move"

mediainfo --Inform="General;mkdir %Recorded_Date%\r\n" *.avi  | %{$_ -replace " \d\d:\d\d:\d\d.000",""}
mediainfo --Inform="General;move %FileName%.avi %Recorded_Date%/%FileName%.avi\r\n" *.avi  | %{$_ -replace " \d\d:\d\d:\d\d.000",""}
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: StarGeek on September 25, 2019, 12:12:00 PM
Quote from: greybeard on September 25, 2019, 07:05:20 AM
When I first ran these commands in the Powershell they outputted a double-byte character set.

If Powershell doesn't think that the output when piped/redirected is in unicode, it will assume it is ascii and "help" you by converting it to unicode.  This is a big problem when trying to extract embedded preview images.  See this post (https://exiftool.org/forum/index.php/topic,8137.msg41663.html#msg41663) for details and links.

Title: Re: How can I organize my videos in folders according to year-month-day
Post by: greybeard on September 25, 2019, 12:19:25 PM
Quote from: StarGeek on September 25, 2019, 12:12:00 PM
Quote from: greybeard on September 25, 2019, 07:05:20 AM
When I first ran these commands in the Powershell they outputted a double-byte character set.

If Powershell doesn't think that the output when piped/redirected is in unicode, it will assume it is ascii and "help" you by converting it to unicode.  This is a big problem when trying to extract embedded preview images.  See this post (https://exiftool.org/forum/index.php/topic,8137.msg41663.html#msg41663) for details and links.

Thanks - it caused me much confusion
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: lamola on September 29, 2019, 03:35:28 AM
THANKS greybeard and StarGeek but I find the command very confusing and dangerous.
I hope to see if Phil can help me in this, I have hundreds of files to order and I don't like the idea of ​​doing it one by one.
Thanks for everything
lamola
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: greybeard on September 29, 2019, 04:36:32 AM
Quote from: lamola on September 29, 2019, 03:35:28 AM
THANKS greybeard and StarGeek but I find the command very confusing and dangerous.
I hope to see if Phil can help me in this, I have hundreds of files to order and I don't like the idea of ​​doing it one by one.
Thanks for everything
lamola

I understand your caution.

Whatever solution you go with its recommended to back everything up before you start.
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: Phil Harvey on September 29, 2019, 06:19:36 AM
Quote from: lamola on September 29, 2019, 03:35:28 AM
I hope to see if Phil can help me in this,

I don't have time to read this whole thread.  Is the problem that PowerShell mangles the files?  If so, the solution is simple: Don't use PowerShell.  Use cmd.exe instead.

- Phil
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: greybeard on September 29, 2019, 07:36:06 AM
No the problem is that Exiftool doesn't currently parse out certain dates from some types of video file (and the OP would rather use Exiftool than Mediainfo)
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: StarGeek on September 29, 2019, 12:06:48 PM
You can find a sample file in this post (https://exiftool.org/forum/index.php/topic,10450.msg55147.html#msg55147). greybeard figured out that a time stamp that MediaInfo (https://mediaarea.net/en/MediaInfo) detects but exiftool does not is probably in a LIST chuck in the file.

The PowerShell posts are about figuring out an alternative way to do what the user wants since exiftool doesn't read the timestamp.
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: lamola on September 29, 2019, 02:48:02 PM
Hello everyone,
Programs like DVdate by Paul Gagla and Windv123 by Petr Mourek read and manage the date and time of the video.
Windv123 captures the video from the video camera and records it on the computer with the name of the file "year-month-day-hour-minutes-seconds-frames" of the first frame of the video.
DVdate overwrites the date and time of the capture in each frame. However, none of the programs can be used to move the videos to directories sorted by "year-month-day".
The videos are in .avi format and codec minidv of sony, canon and panasonic
Thanks.
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: Phil Harvey on September 29, 2019, 08:14:16 PM
Right, thanks.

The LIST_movi chunk that greybeard refers to in the AVI file is the audio/video data, which in general Exiftool doesn't parse.  ExifTool is a metadata utility, and unfortunately it seems as if there is no date/time metadata in either the AVI or MP4 video posted.

I have made some exceptions, such as AVCHD (M2TS) files, for which ExifTool does parse the video stream (because these files have no metadata), but I really don't want to get into this can of worms for other formats if I can avoid it.  (Read here for a bit of a rant about this (https://exiftool.org/commentary.html#AVCHD).)

- Phil
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: lamola on September 30, 2019, 03:22:55 AM
Thanks Phil, I understand that exiftool can't do anything because avi-minidv files don't contain capture date metadata. However, they do have this data at fixed points in the structure of each video frame.
On the other hand, in the capture I made of the video camera, the file name I gave to the capture was "Tapennn.aaaammdd-hh-mm-ss.xx.avi" where
yyyy year, mm month, dd day, etc "
How could I sort these files into directories according to year-month-day and checking that the date string is correct?
Thank you
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: Hayo Baan on September 30, 2019, 04:13:58 AM
Quote from: lamola on September 30, 2019, 03:22:55 AM
Thanks Phil, I understand that exiftool can't do anything because avi-minidv files don't contain capture date metadata. However, they do have this data at fixed points in the structure of each video frame.
On the other hand, in the capture I made of the video camera, the file name I gave to the capture was "Tapennn.aaaammdd-hh-mm-ss.xx.avi" where
yyyy year, mm month, dd day, etc "
How could I sort these files into directories according to year-month-day and checking that the date string is correct?
Thank you

I see no year in your filename, but assuming the aaaa is the year, you could do something like this

exiftool '-directory<${filename;s/Tape\d+\.(\d{4})(\d{2})(\d{2})/$1$2$3/} -if '$filename =~ /Tape\d+\.\d{8}\-\d{2}-\d{2}-\d{2}/' FILESorDIRS

This would put your files in a directory named yyyymmmdd. I split the year, month and day into separate parts to easily allow changing their order, adding delimiters, etc. (e.g. .../$1-$2-$3/... would add dashes between the year, month and day parts). If this isn't what you want, please provide an example that illustrates what you want to achieve.

Note: if you're on windows replace the single quotes with double quotes.
Title: Re: How can I organize my videos in folders according to year-month-day
Post by: lamola on September 30, 2019, 08:22:54 AM
Sorry, the initial year was in Spanish (my source language) year in Spanish is año.
I will test your command.
Thanks