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

greybeard

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",""}

StarGeek

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 for details and links.

* 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

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 for details and links.

Thanks - it caused me much confusion

lamola

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

greybeard

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.

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

greybeard

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)

StarGeek

You can find a sample file in this post. greybeard figured out that a time stamp that 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.
* 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

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.

Phil Harvey

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.)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

lamola

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

Hayo Baan

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.
Hayo Baan – Photography
Web: www.hayobaan.nl

lamola

Sorry, the initial year was in Spanish (my source language) year in Spanish is año.
I will test your command.
Thanks