export csv with foldername and total time

Hmm, I gave you two export scripts, which do work, when one know how to apply them.

I do understand your folder organisation.
Maybe there are some problems bundled together.

  • The folder depth varies.
  • There is no standard tag-field data to use for looping.
  • Maybe Mp3tag is not able to loop on calculated folder parts resp. substrings of pseudo tag-fields like %_path% or %_folderpath%.

The pseudo tag-fields %_directory% and %_parent_direxctory% are related to the audiofile in a relative manner, which means, one step up resp. two steps up from the point of view of the audiofile.

But you want look in an absolute manner to a common folder level within the folderpath, which starts at the diskroot resp. in one designated master folder.

You want to get the sum of playtime of all audiofiles within each 'Artist - Album' folder, including all audiofiles in possible subfolders, summed up per 'Artist - Album' folder, beneath the main root folder 'c:\importfolder'.

The problem will loose its complexity, when you are willing to create one or more user defined tag-fields.
For example, you can split the folderpath into its components, and use the common part of the folderpath, stored in a tag-field, as the argument in an export $loop function.

See there to get an impression what could be done:
Easy way to get directory names above Parent?
mit _DIRECTORY Überordner umbenennen (zb bei 2xCD)

You can try to store the result from the following expression into an user defined tag-field within each audiofile and run an export loop on this tag-field over all files and sum up the length in seconds resp. use only the first item per loop and evaluate the placeholder %_total_time%.

%_workingpath%$regexp($replace('*'%_folderpath%,'*'%_workingpath%,),'^(.+?)\\\\.*$','$1')'\'

I assume you want to create a TSV file using the TAB character created by $char(9) as the delimiter between the items?

Using the proposal from above I am able to create a text output like this ...

Duration in Seconds ==> Folderpath

  2458 ==> M:\MUSIK\ROCK\Y\Yes\1969 - Yes\
  1082 ==> M:\MUSIK\ROCK\Y\Yes\1970 - Something's Coming\
  2452 ==> M:\MUSIK\ROCK\Y\Yes\1971 - The Yes Album\
  2429 ==> M:\MUSIK\ROCK\Y\Yes\1972 - Fragile\
  4530 ==> M:\MUSIK\ROCK\Y\Yes\1972 - Close To The Edge\
  4428 ==> M:\MUSIK\ROCK\Y\Yes\1993 - Affirmative\
  9380 ==> M:\MUSIK\ROCK\Y\Yes\2003 - The Ultimate Yes (128kB)\
  9381 ==> M:\MUSIK\ROCK\Y\Yes\2003 - The Ultimate Yes.35th AC\
  8567 ==> M:\MUSIK\ROCK\Y\Yes\2003 - The Yes Story.Gold\

 44707 = Total Seconds
12:25:07 = Total Time

DD.20110517.2058.CEST