Version change 09/08/2009 - Now removes duplicate genres from an xml file. For example, if it has the genre 'comedy' three times, it will automatically remove the extra two 'comedy' genres.
There may be a better way to do this, but this is how I've been doing it and I wanted to make it available to others. If you are using Media Browser and go to sort by Genre, there may be genres you don't want. Or there may be genres that you want renamed. The scripts I am posting will allow you to do both, genre substitutions and genre removals from .xml files (ie: mymovies.xml).
I know it's not fun to read a ton of instructions so I will try to make this short, but I recommend you read this so you know how to use the scripts. If you have questions you can post in the comments or email me.
Overview of the scripts
Below is a list of the scripts and what they do. Before you run any of them, you need to edit the settings in the _Settings.txt file.
I recommend you run this script first. It will look through all of the movie xml files and will build a list of each unique genre. You will use the results of the script (Genres.txt) to tell the next script what to do.
This script takes your desired changes and implements them by modifying the xml files that need the specified changes.
This script restores the original .xml files before changes were applied. MakeBackup must be =True in the settings file before running ChangeGenres.vbs if you want to make backup copies.
Using the scripts
Start off by extracting the .zip file into a folder. You want all the scripts and related text files to be in the same folder.
Open the _Settings.txt file. There are some instructions inside but basically here's what you will do.
1) Folders line. Here you set the folder or folders you want to run the scripts against. I have 3 folders that have movies, so for me this line reads Folders=E:\Movies,F:\Movies,G:\Movies. If you only have one movie folder (ex: C:\My Movies\Movies) then your's will read Folders=C:\My Movies\Movies. Separate more than one path with a comma (like my example above).
2) File line. This tells the script the name of the .xml file you want to process. For most people this will be mymovies.xml. So it would read File=mymovies.xml
If your setup uses a different .xml file just set it to be the name of your xml file. Ex: File=yourfile.xml
3) ShowCompletedBox line. If you want to know when the script is finished use ShowCompletedLine=True. If you are running the scripts as a schedule task and you don't want interaction, set it to False. If you have a lot of movies, the script will take a little bit. It's not too bad though. In testing it was about 3 minutes to process 100 movies.
4) MakeBackup line. If you want a backup copy of the .xml file before it gets changed, set this to True. Ex: MakeBackup=True. This will create a file called mymovies.xml.bak (or whatever your file is) and will be the .xml file before changes were made to it.
These settings are used by all scripts. So the first thing you want to do is open _Settings.txt file and edit the settings.
Building a list of genres
Now you can run the BuildGenreList.vbs script. While it is running (same goes for the other script) there will be a file in the folder called _StatusLog.txt. Open this file and you can see how far along the script is. While it is open you will not see the new data being written. After you close it you can re-open it and get refreshed progress. Running this script is optional. If you want to skip it, just create a text file called Genres and in it put the stuff you want changed. Something=Something Else to change, or Something=- to remove.
When it completes, and you will get an annoucement if you set ShowCompletedBox=True, you will have a Genres.txt file in the folder. Open it and you should see each genre in your collection.
Making Genre Changes
You will set how you want things changed using the Genres.txt file.
1) To substite a genre use this syntax: something=something else. So if I want Feel Good changed to Comedy I would find Feel Good in the text file and follow it with =Comedy. So, Feel Good=Comedy. That will change any genre called Feel Good to be Comedy.
2) To remove a genre, find it in the text file and follow it with =-. That's an equals sign and then a minus sign. This will completely remove the genre from the xml files.
Example: Monster Movies=-
Now run the ChangeGenres.vbs script. Again, you can check on it's progress by opening the _StatusLog.txt file. This will tell you what movies have been changed and any actions performed. If, in the _Settings.txt file you have MakeBackup=True, when this runs it will make a copy of the xml file before changes with a .bak extension. When the script finishes the _StatusLog.txt file will have a "Done" line
Doing a Restore
Provided you had MakeBackup=True set in the settings file before you ran the ChangedGenres.vbs script, you will have the ability to restore your original .xml files. The RestoreFromBackup.vbs script also uses the settings in the _Settings.txt file to know what directories to run against. You can also have it tell you when done. And, the progress, and changes, are recorded in the _StatusLog.txt file.
Use the scripts at your own risk. During my testing they are working as designed.
I have not tested this with Vista's UAC (User Account Control) enabled. If you have the UAC on then you may need to right click the script and choose 'Run as Administrator' before running them.
When you start the Genres.txt file is empty. You need to either run the BuildGenreList.vbs script, or manually edit the file to have your desired changes.
If you specified an invalid folder it will tell you in the _StatusLog.txt file. If you made a syntax error in the Genres.txt file either no changes will occur where the syntax error is, or you will get incorrect results. If something gets blundered, and you had MakeBackup=True, you can run the RestoreFromBackup.vbs script and it will restore you original .xml files.
I do not have On Error Resume Next enabled in the scripts. That way, if an error occurs the script will stop. If that happens, you can write down the error, or take a screenshot and send it to me.