# export csv with foldername and total time

**URL:** https://community.mp3tag.de/t/export-csv-with-foldername-and-total-time/12016
**Category:** Export
**Created:** [May 16, 2011, 5:16pm UTC](https://community.mp3tag.de/t/export-csv-with-foldername-and-total-time/12016 "2011-05-16T17:16:40Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [May 17, 2011, 4:43pm UTC](https://community.mp3tag.de/t/export-csv-with-foldername-and-total-time/12016/6 "2011-05-17T16:43:44Z")

</div>

> [@hbfan](#):
>
> Thanks for the codes but they do not work. ...

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

> [@hbfan](#):
>
> ... Maybe I should more explain my folder structure: ...

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.

> [@hbfan](#):
>
> ...  
> Here is a sample of the folderstructure:  
> c:\importfolder\kathy reichs - deadly kiss  
> c:\importfolder\patricia cornwell - predator\cd1  
> c:\importfolder\patricia cornwell - predator\cd2  
> ...

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?](https://community.mp3tag.de/t/9324/1)  
[mit \_DIRECTORY Überordner umbenennen (zb bei 2xCD)](https://community.mp3tag.de/t/10728/1)

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')'\'**

> [@hbfan](#):
>
> ...I'm expecting a csv-file with the two entries:  
> kathy reichs - deadly kiss 04:15:23  
> patricia cornwell - predator 06:12:34  
> ...

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

---

_[View the full topic](https://community.mp3tag.de/t/export-csv-with-foldername-and-total-time/12016)._
