If you make regular changes to your WIM files with the use of the /MOUNTRW or /DELETE switches of IMAGEX, then you may have noticed that your WIM files do not shrink in size after you commit the changes back to the file. You could delete 500mb of data from an image file, only to see the file stay the same size, or even grow by a few megabytes. The reason for this is that the data in a WIM file are not actually removed from the file when deleted, rather the references to it’s contents are simply removed; this is a bit like how deleting a file from your C: drive only deletes the reference to it in the allocation table rather than actually scrubbing all the files binary 1’s and 0’s from the disk sectors.
But don’t worry, there is a solution to this which you can use to optimize the size of your WIM files! With the use of the /EXPORT switch of IMAGEX, you simply export the image from the WIM file into a new one, and you can even change the level of compression used. An example of the use of the command is:
ImageX.exe /export existing.wim X new.wim “My optimised WIM file” (where X is the number of the image file you want to export)
If you make regular manual edits to your existing WIM files then you might want to consider including the process of exporting the WIM to a new one into your work routine. However, it is probably not worth using export if you make infrequent or one off changes. One important thing to remember when using the export command is not to lose any of the /FLAGS settings during your export!