This is a script which will take an ESM/ESP made with the ESP Converter and matches/synchronizes records with a master file (such as Morrowind_ob.esm). It automates the process of matching, over-riding records and renumbering. Record matching is done by X,Y grid location for Worldspace CELL and LAND records. For other record types, it matches by EditorID. I have two versions of this script, version 1 was designed for all records to be injected into Morrowind_ob.esm and version 2 was designed to only inject records which over-ride Morrowind_ob.esm. Version 2 assumes there will be no ID conflicts since it only injects over-riding numbers. Version 1 will renumber ID conflicts as necessary since it injects all records into the selected master. The problems with the version 1 design are that the potential maximum number of unique records is reduced by 255 times and also TES4Edit is much slower when loading an ESM/ESP full of injections/override records than it is loading a file whose records are not injected.
The main drive for writing this script was to automate the merging/synchronization of the ~900,000 records of Tamriel Rebuilt into Morroblivion. To those ends, this script does what previously took me 3-5 hours (1-2 hours of manual editing plus an additional 2-3 hours in batch ID renumbering) in less than 5 minutes. I'm not sure why renumbering is so much faster in my script than with the xEdit built-in ID renumber function, but my guess is that the internal function does a lot more safety checks and wasn't designed to batch renumber 500,000 records at a time.
Huge thanks and credit goes to Zilav and the other makers/contributors of xEdit from which I've copy-pasted chunks of script code.
Usage (for version 2): Place this script in the TES4Edit Scripts directory (usually ...\Oblivion\Edit Scripts). Do not add Morrowind_ob.esm as a master prior to running this script, if you do, unexpected and bad things might happen. Within TES4Edit, select the file or records which you want to modify and run the script. A dialog will ask for a master file (default is Morrowind_ob.esm). The script will look at each selected record and compare it to the master file. If it finds a record in the master file which has the same EditorID or Worldspace X,Y coordinate then it will synchronize all references to the selected record with the master record and then either renumber the selected record to override the master record (ie, injection) or alternatively continue using the master record and ignore/delete the selected record. The alternative is useful for a mod like Tamriel Rebuilt which references records from the master but does not over-ride them. When the script completes, the files should now be linked as Master-Plugin.
NOTE: I feel like this goes without saying but BACKUP your original files! These scripts are not quite 2 weeks old and haven't been tested in all situations. Version 2 is the script I suggest using. Version 1 is only included for reference since it includes code that does ID conflict resolution and renumbering.
How to run a TES4Edit script:
1. Right click on your selected target(s),
2. Select 'Apply Script',
3. Use the drown down at the top to select the name of the script you want to run,
4. Click 'OK'.
Update: To avoid confusion, I'm getting rid of the V1_3 from the V2_6 zip file package.