Tes4Mod:TES4Edit

This is a general "how to" for using ElminsterEU's very powerful TES4Edit tool, including Tes4View and Tes4Trans.

For additional usage information, see also TES4Edit/Release Notes. 

General
Download from  .

Activating Edit and Translation Modes
Tes4View downloads as a single binary (an .EXE file), but this single binary can operate in two alternate modes: Tes4Edit (for general editing) and Tes4Trans (for translating mods).
To activate Tes4Edit, either rename the binary to "Tes4Edit.exe" and launch as usual or start Tes4View from the command line with the "-edit" argument (e.g. "Tes4View -edit").
To activate Tes4Trans, either rename the binary to "Tes4Trans.exe" and launch as usual or start Tes4View from the command line with the "-translate" argument (e.g. "Tes4View -translate").

Basic Usage
;Hidden
When comparing mods, use this option to exclude files that are not relevant to the comparison. For example, if you want to see what changes were made in a new version of some plugin, the compare may work a lot better if you mark Oblivion.esm as Hidden before doing Apply Filter.
Usage: Right click the file in left-hand pane and select "Hidden" (before doing Apply Filter).

;Hide No Conflict Rows
When comparing mods you can use this option to show only the rows of data that conflict. 
Usage: Right click in view pane and select "Hide No Conflict Rows".

Choosing Mods to Compare
By default TES4View will choose your active mods. You can click to add/remove mods on startup. There is also a context menu on the list (and all other lists displayed in this type of dialog) which allows you to select all, select none or invert your selection. If you have any modules selected which depend on masters that are available but not selected then these masters will be implicitly selected and loaded after you close the dialog.

Command Line Parameter: Another option for loading specific mods in TES4View is by creating a text file that lists the filenames of the modules you want to load and call TES4View with that filename as parameter. An easy way to do this is:
Create a file called name.tes4modules 
Edit that file and list the modules you want to load. Each on a separate line.
Try to open that file, for the first time you should get a dialog "Windows cannot open this file:"
"Select the program from a list" -> OK
"Browse"
Select TES4View.exe (or TES4Edit.exe)
OK
This should start TES4View with exactly the modules you listed in the file preselected
You can create as many such files as you wish. After going through the "Windows cannot open this file:" dialog once opening any .tes4modules file will always start TES4View directly.

Wrye Bash: You can also use Wrye Bash in a couple of ways to select your active mods:
If you de-activate "Oblivion.esm" in Wrye Bash, you'll deactivate all of the mods that depend on it as well. Which is to say every other mod. You can then select the mod/mods you want to compare.
You can do the same thing by right clicking on the mods column header and choosing Load: None.
If you're repeatedly comparing a large set of mods you also memorize that list of mods in Wrye Bash:
Activate the mod set you want to compare.
Right click on mods column header and select Load: Save List... and pick the name to save the list under.
Afterwards, you'll be able to choose Load:[Name of List] to reload that set of mods.

Cleaning a Dirty Plugin
A much more comprehensive discussion of cleaning mods with TES4Edit can be found  .

This process can help to reduce unnecessary conflicts among different mods. It won't eliminate all conflicts, only those caused by unintentional edits. 

To do this, first make a backup of the plugin you want to clean.

In order to properly clean a mod using TES4Edit, load ONLY that mod into the program.
The reason you only load one mod at a time:  having multiple mods loaded reduces the number of identical to master records that are detected as actual duplicates. Though the process for spotting conflicts is the same filter as that used to clean an individual mod.

Next, right-click on the ESP and select "add filter". On the screen that comes up, you'll have a whole mess of checkboxes. There's one labeled "Conflict status inherited by parent" and that's the ONLY one that should be checked, other than the ones sitting inside the grey boxes with light borders around them. Your screen should look like this: 

Filter settings for mod cleaning

Allow the filter to process. The larger the mod, the longer it'll take. Once that's done, then right click and select "Remove identical to master records" and you'll get some output in the message tab showing you exactly what it removed. 

In version 2.1.2 of TES4Edit and above, an additional cleaning step is available for deleted vanilla references. Once you've cleaned the duplicate records, right click the mod file again, select "Undelete and Disable References". You'll get another list of things that have been undeleted and disabled. This will help prevent one major cause of the game crashing when exiting. More details on this bug  .

Don't be alarmed at how much it finds. Most mods need this sort of cleaning and it would be ideal if everyone who released mods did this cleaning before doing so.

However, it's generally not a good idea to clean most overhaul mods this way. Also, do not try to clean any ESP that has other ESPs as masters (such as patch mods) since this often less than desirable results. It's much better to prune these mods manually if they need it.

After cleaning any mod, you should compare your cleaned version against the original to be sure the process only removed unimportant things. The next section covers how to do this comparison so you can repair any problems created by the automatic cleaning process.

There are additional tutorials about mod cleaning   and  .

Compare Two Versions of a Mod
Start Tes4XXX with the original version of the mod loaded. After it's loaded, right click on the mod file name in the tree view and select the "Compare to" menu item. Then, in the file dialog, select the tweaked version. This will load the tweaked version alongside the original version.

Note that this is superior to loading both versions in the usual way, since when using the "Compare to" command will load the tweaked with the same Load Order ID as the original version. This makes it possible to directly compare records which are newly introduced in both the original and the tweaked version.

Another good strategy, especially if you've been cleaning/removing stuff from your changed version, is to load TES4Edit with the changed version and then do the "Compare to" against the original. The advantage here is that you can use "Copy as Override into" to restore records that have been deleted from the changed version.  

TES4Edit comparison steps:

#Load TES4Edit with your cleaned file active.
#Right-click the plugin and pick "Compare to...".
#Pick the original "dirty" plugin.
#Hide Oblivion.esm and any other masters that are not relevant to the comparison (best to only leave visible the two files you are comparing changes on).
#Apply Filter (be sure to pick Flatten Blocks, Flatten Cell Children, Assign Persistent Worldspace Children to Cells, Conflict Status Inherited by Parent).
#Wait a while for it to finish.
#Start exploring the branches of the original "dirty" file and look for white records (these are the ones that got removed in your clean version).
#Restore any records that shouldn't have been deleted using "Copy as override into ..." (pick the clean plugin as the target).
#Save changes and test.

Remove a Master Dependency
In Tes4Edit, right-click on the filename of the tweaked version in the treeview on the left and select "Clean Masters". This will remove all masters listed in the file header which are not referenced (either by definition of an overriden record or by any record containing a reference to any record defined in the master) in this file. You can check that by having a look at the File Header of the file under "Master Files". If the original master has been removed by "Clean Masters" you've done everything right. If not then you've still got references to that master somewhere in the tweaked file.

Note however that it may be preferable to do this with Tes4Gecko's "Edit Master List" command to remove a master since it will tell you which records are blocking removal of a given master and give you the option to remove that record.

See Also
TES4LODGen, a different but also fantastic TESIV utility by the same author
Plugin Cleaning

External Links
FO3 Edit Manual (also applicable for TES4Edit)