Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Add leading zeroes to dates on convert/move? (Read 1098 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Add leading zeroes to dates on convert/move?

My dates are all in year.month.day format without leading zeroes, which foobar of course has no problem with and sorts chronologically. However, I use Poweramp on my phone, which sorts dates lexicographically instead of numerically (e.g. 2013.11.13 gets sorted before 2013.5.27).

I need to be able to convert/move my music to my phone and add leading zeroes to the months and days of dates in that format. I'm currently using %album artist%/[%date% - ]%album%/[%discnumber%.]%tracknumber%. %title%[ '('%track artist%')'] -- is there any way to do this? Someone recommended $date(time) but it doesn't seem to work.

Add leading zeroes to dates on convert/move?

Reply #1
Code: [Select]
$date(%date%)

If you prefer YYYY.MM.DD over YYYY-MM-DD then you can:
Code: [Select]
$replace($date(%date%),-,.)

Check:
http://wiki.hydrogenaud.io/index.php?title...tting_Reference

Edit: By the way you can also use %list_index% in case you want to force sort the way the tracks appeared in your playlist (in case it's without any specific pattern).

Add leading zeroes to dates on convert/move?

Reply #2
Code: [Select]
$date(%date%)

If you prefer YYYY.MM.DD over YYYY-MM-DD then you can:
Code: [Select]
$replace($date(%date%),-,.)

Check:
http://wiki.hydrogenaud.io/index.php?title...tting_Reference

Edit: By the way you can also use %list_index% in case you want to force sort the way the tracks appeared in your playlist (in case it's without any specific pattern).


Thanks for the response!

I'm having trouble getting $date to work. Here's what I had originally and what I'm winding up with after playing around with $date:



(The | in the second is just my cursor.) I've played around with $date a few different ways and can't get the date to output. Without brackets, with YYYY-MM-DD, whatever -- it doesn't output.

Add leading zeroes to dates on convert/move?

Reply #3
Okay, since I can't find an elegant solution I just coded my way out of the problem as inelegantly as possible 

Code: [Select]
$left(%date%,4).$ifgreater($left($right(%date%,$sub($len(%date%),5)),2),9,$left($right(%date%,$sub($len(%date%),5)),2),$pad_right($left($right(%date%,$sub($len(%date%),5)),1),2,0)).$ifgreater($len(%date%),7,$ifgreater($right(%date%,2),9,$right(%date%,2),$pad_right($right(%date%,1),2,0)),00)


That outputs dates in YYYY.MM.DD format with leading zeroes, from inputted dates that don't have leading zeroes and may only have years and months (or only just years).

Add leading zeroes to dates on convert/move?

Reply #4
Hmm, I guess $date() can't interpret the YYYY.(M)M.DD format after all. I'd personally do a mass conversion on your tracks so YYYY-MM-DD is used by default and no further conversion is needed when you push files to your phone.

1) Do a 'Library/Search' with the pattern below. This will filter our operation to the problematic files only.
Code: [Select]
%date% HAS .

2) Backup the DATE field of these files, just in case we mess up something in the next step. Select said tracks, 'right click/properties/automatically fill values'. Choose the 'Other...' option from the dropdown menu and input '%date%' to the field. For 'Pattern' choose something like '%date2%'. After pressing OK you'll have a DATE2 field that serves as temporarily copy of DATE.

3) Right click on DATE, select 'split values'. Delete whatever is in the dialog already and input a single '.' (dot) instead. That will break '2015.5.12' down into '2015; 5; 12'.

4) Reassemble the values in DATE using the correct form. To do so, click 'Tools/Automatically fill values...'. Source should be set to 'other' and you should input the code below.
Code: [Select]
$num($meta(date,0),4)-$num($meta(date,1),2)-$num($meta(date,2),2)

Pattern should be '%date%'. Check if this is indeed looking good with all your files, click OK.

5) Double check if all files are looking good, if they do, you can delete the DATE2 field.

6) Make sure each new files is formatted correctly before added to your library. Fix them if necessary. Should be much easier to do so for just a few albums.

Add leading zeroes to dates on convert/move?

Reply #5
Hmm, I guess $date() can't interpret the YYYY.(M)M.DD format after all. I'd personally do a mass conversion on your tracks so YYYY-MM-DD is used by default and no further conversion is needed when you push files to your phone.

1) Do a 'Library/Search' with the pattern below. This will filter our operation to the problematic files only.
Code: [Select]
%date% HAS .

2) Backup the DATE field of these files, just in case we mess up something in the next step. Select said tracks, 'right click/properties/automatically fill values'. Choose the 'Other...' option from the dropdown menu and input '%date%' to the field. For 'Pattern' choose something like '%date2%'. After pressing OK you'll have a DATE2 field that serves as temporarily copy of DATE.

3) Right click on DATE, select 'split values'. Delete whatever is in the dialog already and input a single '.' (dot) instead. That will break '2015.5.12' down into '2015; 5; 12'.

4) Reassemble the values in DATE using the correct form. To do so, click 'Tools/Automatically fill values...'. Source should be set to 'other' and you should input the code below.
Code: [Select]
$num($meta(date,0),2)-$num($meta(date,1),2)-$num($meta(date,2),2)

Pattern should be '%date%'. Check if this is indeed looking good with all your files, click OK.

5) Double check if all files are looking good, if they do, you can delete the DATE2 field.

6) Make sure each new files is formatted correctly before added to your library. Fix them if necessary.


Oh, I found a solution in my second reply to you -- so sorry to make you do more work 

I appreciate the time you spent though!

Add leading zeroes to dates on convert/move?

Reply #6
I actually saw your comment before I wrote the bulk of it. I still think you should fix your tags. Taking care of the root of the problem is better than bandaid fixing. Not to disregard your solution.