Kodi Community Forum

Full Version: How Could I add a Genre line to every NFO file in a directory ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How could I do this, or is this even possible? I have lots of movies Id like to group together in certain channels on my PSEUDO TV
So I would like to add a GENRE line to heaps of movies, Say all my movies that are Australian, I would like to Add <genre>OZ<genre> next to the genre line already in the nfo file.
Would be easier than manually adding this line to all 512 I have.
Drop them all into a temp folder, run some sort of script perhaps then drop them all back to the movie directory.
Then I could do this for all tarantino movies, king movies, etc etc.
Any Ideas?
you could do a quick and dirty script exactly like you said, read the file into a buffer, search and replace buffer <movie> with <movie>\n<genre>OZ</genre>, save buffer back to a file
Yea, that's a tough one and depends on how your movies are organised.
If all your OZ movies are in one Source folder, you could use Notepad++ and run a regex search and replace to add a new tag.
But if they are scattered, then the easiest would be to edit the kodi database.

Set up a test install of Kodi. Portable install if you are using Windows.
Scrape all your movies into the library.
In the movie table of the database, edit c14 and add your new genre / OZ with a space either side of the forward slash.
Problem is this only changes the the genre in the movie table, but not in the genre table, or the genre_link table. Its an incomplete edit.
To make a complete edit is too complex and time consuming, to the point that you may as well just edit nfo files.
So you need to export the library to nfo files, delete your library, then scan back so Kodi can create the new genre links automatically.
You could filter c21 to show any entry containing Australia, and a SQL query to append / OZ to the existing genre
(2023-01-29, 06:26)jepsizofye Wrote: [ -> ]you could do a quick and dirty script exactly like you said, read the file into a buffer, search and replace buffer <movie> with <movie>\n<genre>OZ</genre>, save buffer back to a file

LOL, I know thats what I need, but I don't know how to do it. If all the movies were in directory e:\movies\temp do you think you could show me ? if its too much its ok. Cheers
@OzDrDj oh i didnt read it that way, i just thought you meant logistically how could you not physically
i could do something, it would be generic, i assume you need something in a windows .cmd flavor?
Karellen, lmao, Is that Spanish, just jokes, You know, back in the 80s I probably would have understood that. Thanks to Windows I forgot all my programming stuff. I used to be able to do everything from dos. Write programs to do things like this in GWBasic. Now I am a dumb bunny. I have added Added some other Genres before, that seem to have stayed in the system.
I am thinking jepsizofye has the way to go. A quick batch file or script is the way to go, however, I don't know how to do that anymore either.
here you go https://paste.kodi.tv/exajolawut

assumes all nfos are in 1 folder
runs in current folder scanning all .nfo, prints each line from said nfo to a new nfo of the same name in a folder under the current named "new", when it sees "<movie>" it will echo an additional line after "<genre>OZ</genre>

cd to the nfo folder and run the script from there

it will duplicate all the nfos to the subfolder "new" with the added genre, did this for safety to avoid overwriting originals
change OZ to whatever genre

EDIT:

afterthought, you can probably duplicate line 7 as many times as you want to insert multiple genre tags
TMM offers a bulk editing option in the context menu which allows you to set a genre to all selected items, filter by genre and select all - easy
I did eventually, Do a complete rebuild of the kodi system. Wiped all NFOs and started from scratch just to make sure there were no errors. As I added the movies back in, I added certain new genres to certain movies, OZ for my Aussie movies, MU for MArvel universe, 007 for James Bond, Kubric, King, Shyamalan, Clint, etc etc.
Now these movies can be instantly added to certain movie channels in Psudeo TV live.