# How to transform a batch of DumpSaved .mx files to .m file conveniently?

I have many DumpSaved .mx files under a directory. They are generated in Linux OS. The .mx files are platform dependent. But I want to use the data stored in these .mx files in Windows OS.

So I want a method to transform batch of .mx under a directory into Platform independt .m files conveniently.

-
Related: (2900), (25027) –  Mr.Wizard Jul 21 at 10:55

This is an interesting question but I'm not sure it's solvable in a general way. MX files are not really definitions but rather low level kernel state data, as I understand.

A potential, limited method would:

1. Record a "snapshot" of all definitions

3. Record a second "snapshot" and look for changes

4. Copy new/changed definitions and export them to a .M file

To even attempt this it would be helpful to to define limitations of the class of data in the .mx files.
For example: are they all OwnValues/DownValues definitions made in the same (Global?) context?

A rough start of this is shown in answer to: DumpSave for the forgetful

-
You are right. I forgot that in the general case I even don't know what variable hold in those .mx files. Anyway, in terms of my problem at hand right now, situation is simpler. These .mx files stored same set of variable, so I can skip the step find changes between two snapshot, but I still don't know how write codes to solve this simpler problem. –  matheorem Jul 21 at 11:15
I mean how to do it in a batch mode. I lack experience in file manipulation. If I do it manually, I have to manully change filename, I just <<name1.mx then Save["name1.m",{symbol1,symbol2,...}]  then Clear[symbol1,symbol2,...] ,...... –  matheorem Jul 21 at 12:06
@matheorem I'm about to leave for the day so I cannot work out the details, but you mean you have the names symbol1, symbol2 etc. that represent all the data you need to copy? In that case you should be able to use a loop like Do[Get[filename]; Save[StringDrop[filename, -1](* drop "x" *), {symbol1, symbol2, ...}]; Remove[symbol1, symbol2, ...];, {filename, listOfFileNames}]` -- which isn't far from what you just wrote. I'm not sure if this is helpful or not. –  Mr.Wizard Jul 21 at 12:37