Parsing a portion of current folder name to rename files

say i have a lot of folders in the uniform format of
%artist% - yyyy-mm-dd - venue, city, state
Led Zeppelin - 1973-12-01 - Madison Square Garden, New York, NY

with files named
01. %title%.flac
02. %title%.flac
03. %title%.flac
04. %title%.flac
05. %title%.flac
06. %title%.flac
07. %title%.flac
08. %title%.flac

the track numbers at the beginning of the filename are not tags and not in the tags AFAIK, as the tracks have discnumbers and instead of 1,2,3,4,5,6,7,8 are really disc1 1-5, and disc 2 1-3

id like to automatically parse yymmdd and rename the file from something like
01. Stairway to Heaven.flac

if i was renaming it manually i would use
lz731201d%discnumber%_ $num(%track%,2)_$replace(%title%, ,_)

im doing one band at a time so the 'lz' is easy to add to the syntax and doesnt need to be parsed. but i need to automatically parse the yymmdd for multiple folders

how would one do that?


See here for some hints on how to post strings as they are:

fixed the code thanks

To get the first part extracted, you could try:
$regexp('Led Zeppelin - 1973-12-01 - Madison Square Garden, New York, NY',^(.).*? (.).*? - \d\d(\d\d)-(\d\d)-(\d\d) - .*,$1$2_$3$4$5)
which lead to:

but im not trying to do a single folder im trying to parse from folders in same format, like
Led Zeppelin - 1973-12-01 - Madison Square Garden, New York, NY
Led Zeppelin - 1973-12-04 - Knickerbocker Arena, Albany, NY
Led Zeppelin - 1973-12-07 - Spectrum, Philadelphia, PA
Led Zeppelin - 1973-12-09 - Boston Garden, Boston, MA

and then ill have to do

Boston - 1974-02-01 - Madison Square Garden, New York, NY
Boston - 1974-02-04 - Knickerbocker Arena, Albany, NY
Boston - 1974-02-07 - Spectrum, Philadelphia, PA
Boston - 1974-02-09 - Boston Garden, Boston, MA


again they are in uniform format but some artists have one word names, some have four or more word names

To get just the date, try
$regexp('Led Zeppelin - 1973-12-01 - Madison Square Garden, New York, NY',^.*? - \d\d(\d\d)-(\d\d)-(\d\d) - .*,$1$2$3)

To get just the date, try
$regexp('Led Zeppelin - 1973-12-01 - Madison Square Garden, New York, NY',^.*? - \d\d(\d\d)-(\d\d)-(\d\d) - .*,$1$2$3)

No, they are not as they have different patterns to generate the initials
So there are different band names - I would have filtered for those that match the two-part names and then apply the expression anyway as that would automate a fair number of entries.

Then you could modify the expression and the filter to cater for just 1 part names and then treat the next batch... but that is up to you.

i dont need to generate the initials, can type them in myself as i will run the script forhundreds of folders for one artist at a time. ideally i want it to ignore everything in the folder name and just parse the date

if its easier i could bulk edit the folder names and take the artist out and add it back later so the folders just begin with dates

Have tried my suggestion

Instead of the real string, insert %_directory%:
$regexp(%_directory%,^.*? - \d\d(\d\d)-(\d\d)-(\d\d) - .*,$1$2$3)

in which converter do i enter the above expression? nothing works when i put it in 'tag>filename' or 'filename>filename' (the latter of which requires two fields)

Could you post a screendump - as that would be the right place.

i fixed your syntax from 'driectory' to 'directory' and its now parsing the folder name within tag>filename converter,
normally i would use tag>filename converter and enter
lz731201d%discnumber%_$num(%track%,2)_$replace(%title%, ,_)

replacing lz731201 with
$regexp(%_directory%,^.*? - \d\d(\d\d)-(\d\d)-(\d\d) - .*,$1$2$3) returns the entire foldername and doesnt parse the date

i could probably bulk edit the folders to

731201 - Madison Square Garden, New York, NY

to avoid the extra formatting

Screendumps would tell so much more.
I am completely lost to what you do, which data can be found where and, given the exmple strings for folder names, I cannot reproduce that

is returned. Is this a differently structured folder name?
^.*? - \d\d(\d\d)-(\d\d)-(\d\d) - .*,$1$2$3)
works with
Led Zeppelin - 1973-12-01 - Madison Square Garden, New York, NY
as well as
Boston - 1974-02-09 - Boston Garden, Boston, MA

oops sorry, my mistake, the folders were
Led Zeppelin - 1973-12-01 Madison Square Garden, New York, NY
Led Zeppelin - 1973-12-01 - Madison Square Garden, New York, NY

seems to be working now, am testing with different artists

one more question, kind of an aside is there an easy way to bulk rename folders from

Artist - DD_MM_YY Venue, City, State
Artist - YYYY_MM_DD Venue City state

doesnt need to be in mp3tag, perhaps theres a linux or windows script that would do it easily

i can do it in a few steps using mp3tag and bulk rename in ubuntu but there is probably an easier way. the old folder names are terrible because they dont sort chronologically

thanks so much!

Try another regular expression for _DIRECTORY:
$regexp('Artist - 01_02_20 Venue, City, State',(.*) - (\d+)_(\d+)_(\d+) (.*),$1 - $4_$3_$2 $5)

Use either Convert>Tag-Tag or an action of the type "Format value".
I wonder where 2 extra digits for the YY should come from.

tried that expression in 'format value' and it copied files from
"Boston - 01_01_11 Madison Square Garden, New York, NY"
"Artist - 20_02_01 Venue, City, State"

I think by now you should be able to adapt such an expression and replace the test string with the source variable.

yes thanks! this worked great for YYYY beginning with 20YY
$regexp(%directory%,(.*) - (\d+)(\d+)_(\d+) (.*),$1 - 20$4-$3-$2 $5)

ill have to do 20th and 21st century dates in two batches, but thats fine

actual final script for file renaming

$regexp(%_directory%,(.*) - (\d+)_(\d+)_(\d+) (.*),$1 - 20$4-$2-$3 $5)

note that the 2 and 3 are switched from your originally suggested expression, to yield YYYY-MM-DD

i just installed mp3tag on ubuntu under wine to use the same scripts above that were working successfully under windows

the file rename (convert>tag-filename) works fine, but the folder rename (quick action>format value>_directory) will not work

perhaps a permissions issue?

if you suspect a permission issue then you are the only one to check and test whether changes improve things.