Export 1 .NFO per .MKV file for KODI, Help needed

Hi my first post, thanks for this great piece of software =)

I am hoping I’m making my self clear to what I want.

I know of other threads but I just can’t figure it out.

basically I want some basic metadata from my files exported to 1 separate NFO file for all musicvideos in a folder for KODI

So this is what i got, this script works fine to export a single NFO for kodi.

$filename(%_filename%.nfo)<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<movie>
<title>%title%</title>
   <artist>%albumartist%</artist>
   <album>%album%</album>
   <genre>%genre%</genre>
   <year>%year%</year>
<actor>
        <name>%artist%</name>
        <role></role>
        <thumb></thumb>
        <order>1</order>
</actor>
    </movie>

But it only works for single files.

If I use this script and extract from multiple files I get a single NFO with information of all the files.

$filename(%_filename%.nfo)$loop(%_path%)<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<movie>
<title>%title%</title>
   <artist>%albumartist%</artist>
   <album>%album%</album>
   <genre>%genre%</genre>
   <year>%year%</year>
<actor>
        <name>%artist%</name>
        <role></role>
        <thumb></thumb>
        <order>1</order>
</actor>
    </movie>
$loopend()

So how could I split this file to separate files.

I am ofcourse missing something here and I would really appreciate some assistance..

THX, cheers from Sweden.

See this thread on how to split a single text file into several ones using a .bat file:

Thanks alot !

Very long thread, I will dig in and see if I can get something out of it. Seems most of it is about lyrics.

the techniques stays the same. Instead of
$filename(%_filename%.nfo)
set
$filename(Infobatch.bat)
Then let the export script create a (text) batch file first that contains statements like instead of an e.g. simple
<title>%title%</title>
you set
echo "<title>%title%</title>">> %_filename%.nfo
(repeat that for each line of code)
After the execution of the export script you get into the file system, search for infobatch.bat and execute that batch file.
It should create a number of .nfo files, one for every given filename.

It may be necessary to escape characters with special functions when they appear as part of the data

Hi THX again for your post and quick answear.

I’m sorry but I still don’t get it. Must be retarded i guess.

So to create this infobatch.bat file, I should mark a couple of files, click CTRL+E to export?

and in that file I should take this very short example:

$filename(Infobatch.bat)
echo "<title>%title%</title>">> %_filename%.nfo

the resulting infobatch.bat:

#EXTM3U echo #EXTINF:206,Artist aaa - aaa title >> split_0.nfo echo 01 AAA.mkv >> split_0.nfo echo #EXTINF:200,Artist bbb - bbb title >> split_0.nfo echo 02 BBB.mkv >> split_0.nfo echo #EXTINF:332,Artist ccc - ccc title >> split_0.nfo echo 03 CCC.mkv >> split_0.nfo 

when I run the infobatch.bat file it gives me a file called “split_0.nfo” and that file is empty.

Where does the

come from? That is a typical keyword in a playlist.

To outline the basic procedure:
The export creates a batch file.
The batch file contains the commands to put the xml.statements into a specified .nfo file.
The first line in the export code should end in >%_filename%.nfo (to initally create the nfo-file) while all further lines end in >>%_filename%.nfo (to add further lines to the nfo-file)

You keep all the lines from your original export script only that you preceed every line with echo " and end it as described above.

I have no clue

so I take it the exportfile, short version could look like this?

$filename(Infobatch.bat)>%_filename%.nfo
echo "<title>%title%</title>">> %_filename%.nfo
echo "<artist>%artist%</artist>">> %_filename%.nfo

I mark the 3 files frpm my screenshot and export with that..

resulting Infobatch.bat:

>01 AAA.nfo
echo "<title>aaa title</title>">> 01 AAA.nfo
echo "<artist>Artist aaa</artist>">> 01 AAA.nfo

when I run the bat file I get one single file called 01 with no extension. it says

edit, this is the resulting 01 file

"<title>aaa title</title>" AAA.nfo
"<artist>Artist aaa</artist>"

You are following good ole command shell syntax. This means that you have to experiment a little to get a proper filename for the echo command.

$filename(Infobatch.bat,utf-8)
echo "<title>%title%</title>" > "%_filename%.nfo"
echo "<artist>%artist%</artist>" >> "%_filename%.nfo"

creates a batch file that in return produces the .nfo-file.

... it has the inverted commas, though.

Thanks again!

It’s getting closer :grinning_face:

$filename(Infobatch.bat)$loop(%_path%)
echo "<?xml version="1.0" encoding="UTF-8" standalone="yes"?>" >>"%_filename%.nfo"
echo "<movie>" >>"%_filename%.nfo"
echo "<artist>%albumartist%</artist>" >> "%_filename%.nfo"
echo "<title>%title%</title>" >> "%_filename%.nfo"
echo "<album>%album%</album>" >>"%_filename%.nfo"
echo "<genre>%genre%</genre>" >>"%_filename%.nfo"
echo "<year>%year%</year>" >>"%_filename%.nfo"
echo "<track></track>" >>"%_filename%.nfo"
echo "<plot></plot>" >>"%_filename%.nfo"
echo "<director></director>" >>"%_filename%.nfo"
echo "<actor>" >>"%_filename%.nfo"
echo "<name>%artist%</name>" >>"%_filename%.nfo"
echo "<role></role>" >>"%_filename%.nfo"
echo "<thumb></thumb>" >>"%_filename%.nfo"
echo "<order>1</order>" >>"%_filename%.nfo"
echo "</actor>" >>"%_filename%.nfo"
echo "</movie>" >>"%_filename%.nfo"
$loopend()

If I export these lines. I get all 3 NFOs named same as the MKVs.

here is the first one:

"<?xml version="1.0" encoding="UTF-8" standalone="yes"?>" 
"<movie>" 
"<artist>albumartist aaa</artist>" 
"<title>aaa title</title>" 
"<album>aaa album</album>" 
"<genre></genre>" 
"<year>2025</year>" 
"<track></track>" 
"<plot></plot>" 
"<director></director>" 
"<actor>" 
"<name>Artist aaa</name>" 
"<role></role>" 
"<thumb></thumb>" 
"<order>1</order>" 
"</actor>" 
"</movie>" 

which is correct exept the " symbols between every line in the NFO. I used Notepad++ to remove them and KODI scanned the musicvideos just fine.

Any idea for solution here?

If not, I guess I can live with having one extra step to remove the markers, symbols whatever they are called. .

You can try to "escape" the < and > and ? characters with a ^ like this:

echo ^<^?xml version="1.0" encoding="UTF-8" standalone="yes"^?^> >>"%_filename%.nfo"
echo ^<movie^> >>"%_filename%.nfo"

Remove the quotation marks " around the XML start- and end-tags:
OLD: echo "<movie>"
NEW: echo ^<movie^>

This version should work:

$filename(Infobatch.bat)$loop(%_path%)
echo ^<^?xml version="1.0" encoding="UTF-8" standalone="yes"^?^> >"%_filename%.nfo"
echo ^<movie^> >>"%_filename%.nfo"
echo ^<artist^>%albumartist%^</artist^> >> "%_filename%.nfo"
echo ^<title^>%title%^</title^> >> "%_filename%.nfo"
echo ^<album^>%album%^</album^> >>"%_filename%.nfo"
echo ^<genre^>%genre%^</genre^> >>"%_filename%.nfo"
echo ^<year^>%year%^</year^> >>"%_filename%.nfo"
echo ^<track^>^</track^> >>"%_filename%.nfo"
echo ^<plot^>^</plot^> >>"%_filename%.nfo"
echo ^<director^>^</director^> >>"%_filename%.nfo"
echo ^<actor^> >>"%_filename%.nfo"
echo ^<name^>%artist%^</name^> >>"%_filename%.nfo"
echo ^<role^>^</role^> >>"%_filename%.nfo"
echo ^<thumb^>^</thumb^> >>"%_filename%.nfo"
echo ^<order^>1^</order^> >>"%_filename%.nfo"
echo ^</actor^> >>"%_filename%.nfo"
echo ^</movie^> >>"%_filename%.nfo"
$loopend()

Please note the first line
echo ^<^?xml version="1.0" encoding="UTF-8" standalone="yes"^?^> >"%_filename%.nfo"
with only one > in front of "%_filename%.nfo".
This means: fill the text into this filename but OVERWRITE everything that already exists, start from scratch.
If you write two >> in front of "%_filename%.nfo" it means APPEND the text to an already existing file and content. This is the correct way for the second and all following lines in a Windows CMD batch file.

If you always use >>, you add the same content again and again into the same file with every call of the Infobatch.bat

Just for the record:
If you want to indent elements such as the actor name, role, thumbnail and order, you can simply insert the required number of spaces between echo and the individual start-tag.
The export scripts would look like this:

echo ^<actor^> >>"%_filename%.nfo"
echo     ^<name^>%artist%^</name^> >>"%_filename%.nfo"
     ␣␣␣␣ <- additional spaces

THX alot !

I shall try this as soon as I can.

THX for taking your time for this. But my result is still:

"<?xml version="1.0" encoding="UTF-8" standalone="yes"?>" 
"<movie>" 
"<artist>albumartist aaa</artist>" 
"<title>aaa title</title>" 
"<album>aaa album</album>" 
"<genre></genre>" 
"<year>2025</year>" 
"<track></track>" 
"<plot></plot>" 
"<director></director>" 
"<actor>" 
"<name>Artist aaa</name>" 
"<role></role>" 
"<thumb></thumb>" 
"<order>1</order>" 
"</actor>" 
"</movie>" 

does not result in:

"<?xml version="1.0" encoding="UTF-8" standalone="yes"?>" 
"<movie>" 
"<artist>albumartist aaa</artist>" 
"<title>aaa title</title>" 
"<album>aaa album</album>" 
"<genre></genre>" 
"<year>2025</year>" 
"<track></track>" 
"<plot></plot>" 
"<director></director>" 
"<actor>" 
"<name>Artist aaa</name>" 
"<role></role>" 
"<thumb></thumb>" 
"<order>1</order>" 
"</actor>" 
"</movie>" 

because the above Export script does not contain leading and trailing " anymore... :wink:
Please double check if you use the correct version.

This is what I get - just tested again:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<movie> 
<artist>MKV-Albumartist</artist> 
<title>MKV-Title</title> 
<album>MKV-Album</album> 
<genre>MKV-Genre</genre> 
<year>2025</year> 
<track></track> 
<plot></plot> 
<director></director> 
<actor> 
<name>MKV-Artist</name> 
<role></role> 
<thumb></thumb> 
<order>1</order> 
</actor> 
</movie>

from these metadata:

YES ! Cheers mate ! that did the trick !

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<movie> 
<artist>albumartist aaa</artist> 
<title>aaa title</title> 
<album>aaa album</album> 
<genre></genre> 
<year>2025</year> 
<track></track> 
<plot></plot> 
<director></director> 
<actor> 
<name>Artist aaa</name> 
<role></role> 
<thumb></thumb> 
<order>1</order> 
</actor> 
</movie> 

Big thank you from Sweden !