Turn D/M/YYYY into YYYY/MM/DD

Hi everyone,

I am trying to create a list of albums in txt mode, one line per album with the date-modified date in the front, like this:

2009-9-8 Electronica - Daft Punk - Homework

My script:

$filename(albums-only.txt)
$loop(%_folderpath%,1)$regexp(%_file_mod_date%,(\d{1,2})/(\d{1,2})/(\d{4}),$3-$1-$2)    %genre% - $if2(%albumartist%,%artist) - %album% '['$replace(%_codec%,Free Lossless Audio Codec,FLAC)']'
$loopend()

I tried to use the "iflonger" as well as the "ifgreater" function inside the regexp function, but that does not seem to work. How can I have a ZERO precede all those days and months that are less than "less than 10".

Result should be:

2009-09-08....

as well as

2009-10-22 and not 2009-010-022

If anyone knows how to do this, please let me know!

Thank you. :slight_smile:

Hmm ... my computer regional setting is "Deutsch (Deutschland)" and my short date setting is "JJJJ-MM-TT" accordingly to ISO 8601.
Therefore Mp3tag's system variable %_file_mod_date% returns 2009-10-03 and I can use it without any additionally scripting modification.

Try this export script ...

$filename(o:\test\20091003.supertagger.txt)
$loop(%_folderpath%,1)%album%
'1:'%_file_mod_date%
'2:'$regexp(%_file_mod_date%,'(\d{4}).(\d{1,2}).(\d{1,2})','$1=$2=$3')
'3:'$num($regexp(%_file_mod_date%,'(\d{4}).(\d{1,2}).(\d{1,2})',$3),2)
'4:'$num($regexp(%_file_mod_date%,'(\d{4}).(\d{1,2}).(\d{1,2})',$2),2)
'5:'$num($regexp(%_file_mod_date%,'(\d{4}).(\d{1,2}).(\d{1,2})',$1),4)
$loopend()

... and see what results do you get.

DD.20091003.1607.CEST

Thank you Detlev,

that helped - I figured it out and it should work this way:

$num($regexp(%_file_mod_date%,'(\d{1,2}).(\d{1,2}).(\d{4})',$3),2)-$num($regexp(%_file_mod_date%,'(\d{1,2}).(\d{1,2}).(\d{4})',$1),2)-$num($regexp(%_file_mod_date%,'(\d{1,2}).(\d{1,2}).(\d{4})',$2),2)

This yields

2009-09-08    Electronic - Daft Punk - Homework

from what once was

9/8/2009

Thank you! :slight_smile:

Okay, only problem is now that I cannot sort inversely - or at least it seems a bit too confusing for me. Sorting normally works fine now, but the latest date will end up way down on the bottom of the list. When using $loop($sub...)) it ends up as shown below.

$filename(albums-only.txt)
$loop($sub(%_folderpath%,10000000000))$loop(%_folderpath%,1)$num($regexp(%_file_mod_date%,'(\d{1,2}).(\d{1,2}).(\d{4})',$3),2)-$num($regexp(%_file_mod_date%,'(\d{1,2}).(\d{1,2}).(\d{4})',$1),2)-$num($regexp(%_file_mod_date%,'(\d{1,2}).(\d{1,2}).(\d{4})',$2),2)    %genre% - $if2(%albumartist%,%artist) - %album% '['$replace(%_codec%,Free Lossless Audio Codec,FLAC)']'
$loopend()$loopend()

Yields...

2009-10-02    Pop/Rock - Artist A - Album B [FLAC]
2009-09-03    Pop/Rock - Artist C - Album D [FLAC]
2009-09-03    Pop/Rock - Artist C - Album E [FLAC]
2009-09-03    Soundtrack - Artist A - Album T [FLAC]
2009-09-07    Soundtrack - Artist C - Album F [FLAC]
2009-09-08    Electronic - Artist D - Album E [FLAC]

Seems to be the same problem with how the date is displayed internally - how would I fix this looping inversely $loop($sub...))? Any idea? :slight_smile:

Thank you.

I think ... for the latest date at the top you need a formula like this ...
$sub(10000000000,%_file_mod_datetime_raw%)

DD.20091003.1854.CEST

Thank you for your kind help. Since I am only listing albums this does not work, as it ends up showing me multiple lines for albums depending on the minute a file in there was changed, I guess. Is there any way to use the output generated by the regexp (2009-09-22 etc.) for sorting?

Thank you. :huh:

Maybe ...

  • try a loop like $loop(%album%,1)
  • try a formula like $div($sub(10000000000,%_file_mod_datetime_raw%),3600)
  • try a formula like $div($sub(10000000000,%_file_create_datetime_raw%),3600)

DD.20091003.1955.CEST

Alright, I thought I would post what I ended up with - I am quite pleased with this export config. Some problems popped up when using the RAW datetime: for example, if an album gets tagged at 1am of day 1 and another at 9pm of the same day, the RAW times are too far apart to allow for proper sorting. So what I did was generate an 8-digit number by pulling together YYYY-MM-DD to YYYYMMDD. This gets subtracted and from 10000000000 and allows for proper reverse sorting.

Sample script right here:

$filename(whateveryouwant.txt)
                                                        
List created %_datetime%


$loop($sub(10000000000,$num($regexp(%_file_mod_date%,'(\d{1,2}).(\d{1,2}).(\d{4})',$3),2)$num($regexp(%_file_mod_date%,'(\d{1,2}).(\d{1,2}).(\d{4})',$1),2)$num($regexp(%_file_mod_date%,'(\d{1,2}).(\d{1,2}).(\d{4})',$2),2)))$loop(%albumartist%)$loop(%album%,1)$num($regexp(%_file_mod_date%,'(\d{1,2}).(\d{1,2}).(\d{4})',$3),2)-$num($regexp(%_file_mod_date%,'(\d{1,2}).(\d{1,2}).(\d{4})',$1),2)-$num($regexp(%_file_mod_date%,'(\d{1,2}).(\d{1,2}).(\d{4})',$2),2) '['%genre%']' $if2(%albumartist%,%artist) '/' %album% '('%year%')' '['$replace(%_codec%,Free Lossless Audio Codec,FLAC)']'
$loopend()$loopend()$loopend()

Again, thanks for all the help - maybe this helps someone also trying to reverse-sort! :slight_smile:

Yes, this is a rather old thread, but it is worth to demonstrate a simplification for converting MDY date to YMD date.

The given MDY date (Month/Day/Year) should be a valid MDY value and can be of format ...
02/01/2009
02/1/2009
2/01/2009
2/1/2009
02/01/0009
02/01/09
02/01/9
02/1/09
02/1/9
2/01/9
2/1/09
2/1/9
... that means the year must be a 1- or 2- or 4-digit year, the month and day values must have 1- or 2-digits.

The result is a YMD (Year-Month-Day) date of format ...
2009-02-01
... that means, the year will be always a 4-digit year, the month and day values have always a 2-digit format, zero padded at the left side, if needed.
A given 1- or 2-digit year will not be automatically left padded with a century value (what century should be valid?), so that a given year of "9" or "09" will be padded to "0009".

$regexp($regexp(%DATE_MDY%,'(\d\d?)/(\d\d?)/((?:\d\d?)(?:\d\d)?)','0000$3-00$1-00$2'),'0*(\d\d\d\d)-0*(\d\d)-0*(\d\d)','$1-$2-$3')

DD.20110215.0952.CET

Here is a shorter script with the same purpose, ...
sort by Date modified reverse, Albumartist or Artist, Album.

1: $filename($getEnv('USERPROFILE')'\Desktop\Mp3tag.List.Album.DateModReverse.txt',UTF-8)'List created '%_datetime%

2: $loop($sub(4000000,$div(%_file_mod_datetime_raw%,86400)))$loop($if2(%ALBUMARTIST%,%ARTIST%))$loop(%ALBUM%,1)
3: %_file_mod_date%' ['%GENRE%'] '$if2(%ALBUMARTIST%,%ARTIST%)' / '%ALBUM%' ('%YEAR%') ['$replace(%_codec%,'Free Lossless Audio Codec','FLAC')']'$loopend()$loopend()$loopend()

Example output:

List created 2014-09-26 11:57:04

2014-08-05 [Rock] Genesis / Foxtrot (1972) [MPEG 1 Layer III]
2014-06-29 [Hardrock] Tzunami / Reanimation (2005) [MPEG 1 Layer III]
2014-04-30 [Soundtrack] Nine Inch Nails / ''The Perfect Drug'' (1997-06-09) [MPEG 1 Layer III]
2014-03-04 [Other] Gordon Goodwins Big Phat Band /  (2009-03-20) [MPEG 1 Layer III]
2014-03-04 [Electronica] Tipper / Surrounded (2003) [MPEG 1 Layer III]
2014-01-19 [Soul, Jazz, Easy Listening] Sade / The Best of Sade (1994) [MPEG 1 Layer III]
2014-01-12 [Rock] Fehlfarben / 26 1/2 (2006-02-26) [MPEG 1 Layer III]
2014-01-11 [Rock] Aerosmith / Big Ones (1994) [MPEG 1 Layer III]
2014-01-11 [Rock] Aerosmith / Greatest Hits (1980-10-01) [MPEG 1 Layer III]
2013-12-23 [Rock] Alannah Myles / Black Velvet (2007-09-28) [MPEG 1 Layer III]
2013-11-22 [Rock] Michael Fehst, Gerd Klein / The Orange Cover (2008-07-14) [MPEG 2 Layer III]

DD.20140926.1232.CEST

Yes. It is the raw datetime converted to days (60sec/min60min/h24h=86400sec) that makes the difference.
Well done DetLev.