# Text files export/import, with 1 text file by folder

**URL:** https://community.mp3tag.de/t/text-files-export-import-with-1-text-file-by-folder/8222
**Category:** Support
**Created:** [April 10, 2009, 8:32am UTC](https://community.mp3tag.de/t/text-files-export-import-with-1-text-file-by-folder/8222 "2009-04-10T08:32:32Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![BoraBora](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/439d5e/32.png) [@BoraBora](https://community.mp3tag.de/u/BoraBora)
#### Post date: [April 10, 2009, 8:32am UTC](https://community.mp3tag.de/t/text-files-export-import-with-1-text-file-by-folder/8222/1 "2009-04-10T08:32:32Z")

</div>

Hi,

Haven't been there for a while, but let me say first that MP3Tag is nicer than ever. ![:music:](https://community.mp3tag.de/uploads/default/original/1X/2ba05d1ade5eb0d15fc173be6f717dbe63890a70.gif ":music:") However, there's something I can't seem to achieve, probably because I'm doing it the wrong way.

My goal is to save in a text file any tag that can't be deduced from the path/filename (musicians, band members, producer etc.). I can't use a single file for the whole collection because I often reorganize it (add or delete folders etc.). So I went the "_1 folder = 1 file_" way.

Here's my folder structure:

\<Artist\>\<Album Artist\> ¦ ¦ ¦ \<Disc\> ¦ ¦ .wv

To export my tags, I'm using this filename:

```
%_folderpath%%_directory%.txt

```

And the script code is (reduced to 3 tags for this example):

```
$loop(%_path%)%producer%|$meta_sep(musicians,\\\\)|%label%
$loopend()

```

All is well: the result is one text file in each folder (album, single, EP etc.), formatted like this, with one line by track:

```
Nile Rodgers|Tommy Mandell\\\\Steve Ferrone|Reprise
Don Was|Sara Lee\\\\Philippe Saisse\\\\Sonny Emory|Reprise
Don Was|Sara Lee\\\\Sonny Emory\\\\|Reprise
(etc.)

```

Now's the problem: how can I reimport these tags?

If I understand correctly, the "Convert \> Text file - Tag" is only working with one text file for the whole operation. But my way is to have one text file by folder, and I have more than 3000 folders. ![<_<](https://community.mp3tag.de/uploads/default/original/1X/5996dbb474c88b8f9fc49f09dc3858d081055a2d.gif "<\_<")

The "_Import text file_" action, is very nice, but again it seems I can't use it: the whole text is added to one field only. I thought I would import each line to its track, in a tag named "Whole" or something, than use a "Split fields by separator" action. But to achieve this, I need each line in the text file to be added to the right track, instead of every line added to all tracks.

I'm pretty sure there's a workaway. Maybe I'm doing the export the wrong way? If anybody can put me on track with this problem...

---

<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: [April 10, 2009, 4:36pm UTC](https://community.mp3tag.de/t/text-files-export-import-with-1-text-file-by-folder/8222/2 "2009-04-10T16:36:31Z")

</div>

QUOTE (BoraBora @ Apr 10 2009, 12:32) \<{POST\_SNAPBACK}\>

... To export my tags, I'm using this filename:

```
%_folderpath%%_directory%.txt

```

And the script code is (reduced to 3 tags for this example):

```
$loop(%_path%)%producer%|$meta_sep(musicians,\\\\)|%label%
$loopend()

```

All is well: the result is one text file in each folder (album, single, EP etc.), formatted like this, with one line by track:

```
Nile Rodgers|Tommy Mandell\\\\Steve Ferrone|Reprise
Don Was|Sara Lee\\\\Philippe Saisse\\\\Sonny Emory|Reprise
Don Was|Sara Lee\\\\Sonny Emory\\\\|Reprise
(etc.)

```

Now's the problem: how can I reimport these tags?  
...

  
Well, you are on the right way ...  
Saving tag field content into a file is not your problem, you've managed this already.

In order to store back each entry line from your exported textfile to the correspondend physical file in your music folder (that means to restore tag field content into the right file) there have to be a unique link between the source entry line and the target file.

This link or binding is realized by putting the fully qualified filepath string of the current file into the export textfile along with the tag fields content (easy done while exporting) and refer to this path value while restoring.

Your example export/import file should be changed to the following structure:

Nile Rodgers|Tommy Mandell\\\\Steve Ferrone|Reprise|%\_path%

Don Was|Sara Lee\\Philippe Saisse\\Sonny Emory|Reprise|%\_path%  
Don Was|Sara Lee\\Sonny Emory\\|Reprise|%\_path%

  
with %\_path% actually replaced by the current filepath of the correspondend file.

You have to change your export script code:

$loop(%\_path%)%producer%|$meta\_sep(musicians,\\\\)|%label% **|%\_path%** 

$loopend()

Using Mp3tag/converter/textfile-tag  
Filename : %\_folderpath%%\_directory%.txt  
Formatstring: %producer%|%musicians%|%label% **|%path%**  
you should be able to restore all the tag fields content you've saved before.

DD.20090410.2036.CEST

---

<div class="post-metadata">

### Author: ![BoraBora](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/439d5e/32.png) [@BoraBora](https://community.mp3tag.de/u/BoraBora)
#### Post date: [April 10, 2009, 6:42pm UTC](https://community.mp3tag.de/t/text-files-export-import-with-1-text-file-by-folder/8222/3 "2009-04-10T18:42:00Z")

</div>

Thanks a lot for this very complete answer, DetlevD. 🙂

Unfortunately, I still have a problem: trying to importing the file with "_Convert--\>Text file - Tag_" produces this error:

> [@](#):
>
> File "K:\B\B-52's\B-52's (The) ¦ 1998-05 ¦ Time Capsule ¦ LP\%\_folderpath%%\_directory%.txt" cannot be opened for reading.

Maybe I need to create a custom action because the "Convert text file-Tag" can't interpret the "%\_folderpath%%\_directory%" part?

---

<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: [April 11, 2009, 4:48am UTC](https://community.mp3tag.de/t/text-files-export-import-with-1-text-file-by-folder/8222/4 "2009-04-11T04:48:21Z")

</div>

> [@BoraBora](#):
>
> Thanks a lot for this very complete answer, DetlevD. 🙂  
> Unfortunately, I still have a problem: trying to importing the file with "_Convert--\>Text file - Tag_" produces this error: ...

Importing tags from a text file "%\_folderpath%%\_directory%.txt" looks feasible to me.

Can you elaborate how you have created this string?

**File "K:\B\B-52's\B-52's (The) ¦ 1998-05 ¦ Time Capsule ¦ LP\\%\_folderpath%%\_directory%.txt" cannot be opened for reading.**

This string seems to contain a pipe character which is a forbidden character in the filesystem.

DD.20090411.0849.CEST

---

<div class="post-metadata">

### Author: ![BoraBora](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/439d5e/32.png) [@BoraBora](https://community.mp3tag.de/u/BoraBora)
#### Post date: [April 11, 2009, 8:18pm UTC](https://community.mp3tag.de/t/text-files-export-import-with-1-text-file-by-folder/8222/5 "2009-04-11T20:18:10Z")

</div>

> [@DetlevD](#):
>
> Can you elaborate how you have created this string?
> 
> **File "K:\B\B-52's\B-52's (The) ¦ 1998-05 ¦ Time Capsule ¦ LP\\%\_folderpath%%\_directory%.txt" cannot be opened for reading.**
> 
> This string seems to contain a pipe character which is a forbidden character in the filesystem.

I use it as separator between fields in my files. That's the "Alt+0166" character and so far never caused a problem, either in Windows, MP3Tag or Foobar. Still, I wanted to be sure, so I copied 2 folders with 2 files each to a "test" folder, simplified my structure and deleted any potentially problematic character. I even deleted the multivalued tag, just in case. Here's the rundown:

My files :

K:\Tests\B-52s \_ 1990 \_ Dance This Mess Around \_ LP\06 \_ B-52s \_ Dance This Mess Around.wv  
K:\Tests\B-52s \_ 1990 \_ Dance This Mess Around \_ LP\10 \_ B-52s \_ Song For A Future Generation.wv

K:\Tests\B-52s \_ 1998 \_ Time Capsule \_ LP\04 \_ B-52s \_ Quiche Lorraine.wv  
K:\Tests\B-52s \_ 1998 \_ Time Capsule \_ LP\05 \_ B-52s \_ Mesopotamia.wv

The export script filename:

```
%_folderpath%%_directory%.txt

```

The export script:

```
$loop(%_path%)%track%|%title%|%year%|%_path%
$loopend()

```

The result: 1 text file in each folder:

K:\Tests\B-52s \_ 1990 \_ Dance This Mess Around \_ LP\B-52s \_ 1990 \_ Dance This Mess Around \_ LP.txt

```
06|Dance This Mess Around|1990|K:\Tests\B-52s _ 1990 _ Dance This Mess Around _ LP\06 _ B-52s _ Dance This Mess Around.wv
10|Song For A Future Generation|1990|K:\Tests\B-52s _ 1990 _ Dance This Mess Around _ LP\10 _ B-52s _ Song For A Future Generation.wv

```

K:\Tests\B-52s \_ 1998 \_ Time Capsule \_ LP\B-52s \_ 1998 \_ Time Capsule \_ LP.txt

```
04|Quiche Lorraine|1998|K:\Tests\B-52s _ 1998 _ Time Capsule _ LP\04 _ B-52s _ Quiche Lorraine.wv
05|Mesopotamia|1998|K:\Tests\B-52s _ 1998 _ Time Capsule _ LP\05 _ B-52s _ Mesopotamia.wv

```

So far, everything's fine. 🙂 Now the import. "_Convert_" --\> "_Text File - Tag_".

File name:

```
%_folderpath%%_directory%.txt

```

The format string:

```
%track%|%title%|%year%|%path%

```

And again this error:

> [@](#):
>
> File "K:\Tests\%\_folderpath%%\_directory%.txt" cannot be opened for reading.

I'm at a loss... ☹

---

<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: [April 12, 2009, 5:58am UTC](https://community.mp3tag.de/t/text-files-export-import-with-1-text-file-by-folder/8222/6 "2009-04-12T05:58:04Z")

</div>

Because the filepath contains white spaces which break the filepath into multiple components, you have to put quote chars " around the filepath, e. g. instead of %\_path% use **"%\_path%"**.

DD.20090412.0957.CEST

---

<div class="post-metadata">

### Author: ![BoraBora](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/439d5e/32.png) [@BoraBora](https://community.mp3tag.de/u/BoraBora)
#### Post date: [April 13, 2009, 8:59am UTC](https://community.mp3tag.de/t/text-files-export-import-with-1-text-file-by-folder/8222/7 "2009-04-13T08:59:08Z")

</div>

Thanks for your patience, DetlevD. 🙂

I put quotation marks, but the error was still there. I then shuffled a bit my files and switched the path placeholder in the first position and... nothing. Here's my last try:

The text files after the export, each in the right place :

**K:\B\B-52s\B-52s \_ 1990 \_ Dance This Mess Around \_ LP\B-52s \_ 1990 \_ Dance This Mess Around \_ LP.txt**

```
"K:\B\B-52s\B-52s _ 1990 _ Dance This Mess Around _ LP\06 _ B-52s _ Dance This Mess Around.wv"|06|Dance This Mess Around|1990
"K:\B\B-52s\B-52s _ 1990 _ Dance This Mess Around _ LP\10 _ B-52s _ Song For A Future Generation.wv"|10|Song For A Future Generation|1990

```

**K:\B\B-52s\B-52s \_ 1998 \_ Time Capsule \_ LP\B-52s \_ 1998 \_ Time Capsule \_ LP.txt**

```
"K:\B\B-52s\B-52s _ 1998 _ Time Capsule _ LP\04 _ B-52s _ Quiche Lorraine.wv"|04|Quiche Lorraine|1998
"K:\B\B-52s\B-52s _ 1998 _ Time Capsule _ LP\05 _ B-52s _ Mesopotamia.wv"|05|Mesopotamia|1998

```

As you can see, the path is now between quotes. Now the import:

The filename

```
%_folderpath%%_directory%.txt

```

The script:

```
%path%|%track%|%title%|%year%

```

End result:

> [@](#):
>
> File "K:\B\B-52s\B-52s \_ 1990 Dance This Mess Around \_ LP\%\_folderpath%%\_directory%.txt" cannot be opened for reading.

What's weird in the error message is that the placeholders are not converted, as if the action couldn't understand it. ![:huh:](https://community.mp3tag.de/uploads/default/original/1X/f15ee73c0fd9ec3b0db7481f0558638f8ee224ce.gif ":huh:")

---

<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: [April 13, 2009, 12:55pm UTC](https://community.mp3tag.de/t/text-files-export-import-with-1-text-file-by-folder/8222/8 "2009-04-13T12:55:26Z")

</div>

> [@BoraBora](#):
>
> Thanks for your patience, DetlevD. 🙂 ...

Ok, now it's time to rebuild your example in my environment.  
My Folder:  
"O:\Tests\B-52s \_ 1998 \_ Time Capsule \_ LP"

- including files:  
"04 \_ B-52s \_ Quiche Lorraine.wv"  
"05 \_ B-52s \_ Mesopotamia.wv"
- including control textfile:  
"B-52s \_ 1998 \_ Time Capsule \_ LP.txt"

Content of control textfile:

```
04|Quiche Lorraine|1998|"O:\Tests\B-52s _ 1998 _ Time Capsule _ LP\04 _ B-52s _ Quiche Lorraine.wv"
05|Mesopotamia|1998|"O:\Tests\B-52s _ 1998 _ Time Capsule _ LP\05 _ B-52s _ Mesopotamia.wv"

```

Using converter dialog:

 

**Convert** | **Text file - Tag** | **ALT+4**  
_Select format string_  
Filename:  
**O:\Tests\B-52s \_ 1998 \_ Time Capsule \_ LP\B-52s \_ 1998 \_ Time Capsule \_ LP.txt**  
Format string:  
**%track%|%producer%|%year%|"%\_path%"**

 

gives preview:

```
"O:\Tests\B-52s _ 1998 _ Time Capsule _ LP\04 _ B-52s _ Quiche Lorraine.wv" ->
track: 04
producer: Quiche Lorraine
year: 1998

"O:\Tests\B-52s _ 1998 _ Time Capsule _ LP\05 _ B-52s _ Mesopotamia.wv" ->
track: 05
producer: Mesopotamia
year: 1998

```

This works.

Next try.  
Same dialog using filename "%\_folderpath%%\_directory%.txt" gives error message:

```
File "O:Tests\B-52s _ 1990 Dance This Mess Around _ LP\\%_folderpath%%_directory%.txt" cannot be opened for reading.

```

So what's going wrong?

There seems to be something going wrong with the creation of the proper working path.  
The error the message speeks about a "%\_folderpath% ..." situated in the folder structure down under the files home directory, well, such a path cannot work.  
This fault guides us to several assumptions, ... after hours of speculative investigations ..., at last we look again at the dialog window.

We easily can see: right away from the filename entry field there is button to invoke a file browse dialog. Note: There is no option to open a tag field variable pick list!  
It seems so, better to say, it is obvious, that the programmer has not designed or allowed to use tag field variables for assembling the filename!  
The error message makes it obvious: an emebdded %variable% is not substituted by any value.

Result of exploration:  
The dialog "Textfile - Tag" does not allow any tag field variable within the filename edit field.  
In other words: This dialog's filename entry is not scriptable.

This is a bit of a shame, because consequently the use of system variables such as USERNAME or APPDATA is not feasible in the composition of the filename (but this should be allowed anyway!).

DD.20090413.1715.CEST

---

<div class="post-metadata">

### Author: ![BoraBora](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/439d5e/32.png) [@BoraBora](https://community.mp3tag.de/u/BoraBora)
#### Post date: [April 13, 2009, 1:36pm UTC](https://community.mp3tag.de/t/text-files-export-import-with-1-text-file-by-folder/8222/9 "2009-04-13T13:36:20Z")

</div>

> [@DetlevD](#):
>
> Result of exploration:  
> The dialog "Textfile - Tag" does not allow any tag field variable within the filename edit field.  
> In other words: This dialog's filename entry is not scriptable.
> 
> This is a bit of a shame, because consequently the use of system variables such as USERNAME or APPDATA is not feasible in the composition of the filename (but this should be allowed anyway!).

Now I know I was doomed from the beginning. 😃

I guess there's only two ways to achieve what I want to do, right now:

- Use some utility to concatenate my text files in 1 big file, then use the Alt+4 action. Not really easy if I want some of them only to be processed.

- Use the "Import text file" action, which will import every line of the text file in every folder track. Then parse it with a regular expression to delete any line not related to each track. Then parse this line with a "Split fields by separator" action. The second part is quick and easy, but the first one is way beyond my pathetic scripting skills (or sould I say: my total lack of scripting skills 😃 ).

I'll post a feature request in the appropriate forum. Maybe Florian could plan such a feature for a future version, if it seems appropriate to him.

Thanks again for your time, DetlevD, you've been **very** helpful. 🙂

---

<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: [April 13, 2009, 1:55pm UTC](https://community.mp3tag.de/t/text-files-export-import-with-1-text-file-by-folder/8222/10 "2009-04-13T13:55:36Z")

</div>

> [@BoraBora](#):
>
> ...- Use the "Import text file" action, which will import every line of the text file in every folder track. Then parse it with a regular expression to delete any line not related to each track. Then parse this line with a "Split fields by separator" action. The second part is quick and easy, but the first one is way beyond my pathetic scripting skills (or sould I say: my total lack of scripting skills 😃 ). ...

Clever idea - should not be too complicated to implement as you can use the content of %\_path% variable to identify resp. to isolate the correct line of text, and split it by "guess values" afterwards.

> [@BoraBora](#):
>
> ... Thanks again for your time, DetlevD, you've been **very** helpful. 🙂

You are welcome, I'm pleased to help you.

DD.200900413.1755.CEST

---

<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: [April 14, 2009, 6:11am UTC](https://community.mp3tag.de/t/text-files-export-import-with-1-text-file-by-folder/8222/11 "2009-04-14T06:11:56Z")

</div>

> [@BoraBora](#):
>
> ...- Use the "Import text file" action, which will import every line of the text file in every folder track. Then parse it with a regular expression to delete any line not related to each track. Then parse this line with a "Split fields by separator" action. The second part is quick and easy, but the first one is way beyond my pathetic scripting skills (or sould I say: my total lack of scripting skills 😃 )....

Long time ago I have envolved a procedure to do a lookup in a table.  
Maybe you can need this to do your work.  
[Add composer if title matches from text file?](https://community.mp3tag.de/t/5660/11)

DD.20090414.1011.CEST

---

<div class="post-metadata">

### Author: ![BoraBora](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/439d5e/32.png) [@BoraBora](https://community.mp3tag.de/u/BoraBora)
#### Post date: [April 14, 2009, 1:50pm UTC](https://community.mp3tag.de/t/text-files-export-import-with-1-text-file-by-folder/8222/12 "2009-04-14T13:50:16Z")

</div>

> [@DetlevD](#):
>
> Long time ago I have envolved a procedure to do a lookup in a table.  
> Maybe you can need this to do your work.  
> [Add composer if title matches from text file?](https://community.mp3tag.de/t/5660/11)
> 
> DD.20090414.1011.CEST

NowI know what I'll be doing tonight. 😃

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [February 9, 2026, 12:21pm UTC](https://community.mp3tag.de/t/text-files-export-import-with-1-text-file-by-folder/8222/13 "2026-02-09T12:21:29Z")

</div>


