How to programmatically comment out the entire content of multiple
.m source files assuming they start with correct Mathematica syntax? I need it to be robust so the content of the file can be anything as long as it's valid
.m source file.
As the comments of Szabolcs and acl tell you: read in the file contents as text, put the comment characters before-after the text and save it again as text. Packages are stored as plain text files without any front-end dependent cache information, so this method is robust and foolproof.
First I generate a package file that prints a message when loaded:
Now import-export with comments. Notice that the
Checking the file contents: