Help converting Year to a simpler format

I have my Year tag in the iTunes format. Eg 2014-07-31T07:00:00Z.

I want to create folders of all files in the format "Year - Album name", but when I create an action of the type Format value, I used %year% - %album%%_FILENAME%, with _FILENAME in field., but it generates that confusing format.

What expression should I use, to pick up only the first 4 digits, or at lease what's before "-"?

Thanks!

see e.g.

Why do you include the filename in the folder name?

Aren't there many files in the folder?
The format of the year that you show is actually the format for RELEASETIME. I would copy the data from YEAR to RELEASETIME and then cut the YEAR to just 4 digits as that is the format that the standard defines.

To get the year here you have to match 4 digits uninterrupted so to speak.

So in your format for the directory for just the year (the rest you know, although like @ohrenkino has mentioned there's no need for the filename here I'd say) :
$regexp(%year%,.*?(\d{4}).+?,$1)

I actually wrote wrong, the action I really had was: Format Value: C:..%year% - %album%%_FILENAME%, so It kept the original filename and added each song to its album folder. Note that my songs are all in the same folder, that's why I could not just change the folder's name, because the folders don't exist.

The tag is really YEAR, and I tried
$regexp(%year%,.*?(\d{4}).+?,$1)
$if($eql($len(%YEAR%),10),$cutRight(%YEAR%,6),%YEAR%)
$left(%TAGFIELD%,4)

But none of them worked properly. What should I do?

It did not work, it stills creating the folder in the format 2014-07-31T07:00:00Z - Album Name.

Is it in Format Value box?

I tried _FILENAME in the Field, and $regexp(%year%,.*?(\d{4}).+?,$1) in the sequences value.

$left(%year%,4)

so it would look like
%_folderpath%\$left(%year%,4) - %album%\%_filename%
if you want to create the folders in the the same folder where your files are now.
If you want to create the folders elsewhere you have to use an absolute path for the new location.

As an alternative way you can use the converter Tag->Filename with the same format-string. There you have a preview which is very comfortable when you are testing format-strings.

If your year-tag is not always present you can take
%_folderpath%\[$left(%year%,4) - ]%album%\%_filename%
In this case the content in the square-brackets is neglected.

1 Like

Sorry, I didn't test.
$regexp(%year%,^.*(\d{4}).+?$,$1)

Thank you. You're a genius.