I have many DumpSave-d .mx files under a directory. They are generated under Linux. The .mx files are platform dependent, but I want to use the data stored in these .mx files under Windows.

So I want a method to transform a batch of .mx files into platform independent .m files conveniently.

  • $\begingroup$ Related: (2900), (25027) $\endgroup$
    – Mr.Wizard
    Commented Jul 21, 2013 at 10:55
  • $\begingroup$ This is a good example why DumpSave is not a good way to save data. Instead of DumpSave use Export which doesn't write variable names into the file and makes automatic format conversions easy, should you ever need them in the future. You can use mx with Export, but it's probably better to Compress the expression and Export it to "String" instead. $\endgroup$
    – Szabolcs
    Commented Mar 16, 2014 at 14:59

1 Answer 1


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

  2. load a MX file

  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

  • $\begingroup$ 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. $\endgroup$
    – matheorem
    Commented Jul 21, 2013 at 11:15
  • $\begingroup$ 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,...] ,...... $\endgroup$
    – matheorem
    Commented Jul 21, 2013 at 12:06
  • $\begingroup$ @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. $\endgroup$
    – Mr.Wizard
    Commented Jul 21, 2013 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.