I am trying to automate the process of running a Mathematica notebook that takes as an input a .txt file and exports another .txt file. This notebook was not written by me, and I don't fully understand its inner workings, but I think all I need to know is the following parts of the code:
The input statement is:
my_input_file = Import["my_file_name.txt", "Table"];
The export statement is:
Export["exported_file_name.txt", my_input_file_transformed, "Table"]
I would like to run notebook for many (100) different my_file_name.txt
files which I could name however I want to facilitate the import process, e.g. my_file_name_1.txt
, my_file_name_2.txt
, etc., and put them in the same folder as the my_mathematica_notebook.nb
.
Similarly, I would like to save the 100 different exported .txt files, in the same form I input them in order to be able to reconcile each imported-exported pair of files, e.g. something like exported_file_name_1.txt
, exported_file_name_2.txt
I guess my question is how to run the notebook many times for similarly named files and how to export the files as described above. I have read answers on related questions that call a notebook from another notebook, but none that automates the import of .txt files.
My knowledge of Mathematica is very basic, especially that related to file management, so I am unable to translate the answers I found into a solution for my problem. If it helps, I am working on a Linux machine and could use the command line to automate the process if needed.
Any help with this would be very appreciated. Many thanks.
my_input_file
is not a valid Wolfram Language identifier. $\endgroup$myInputFile
would be valid. Wolfram Language supports camel-case, but not snake-case.myInputFile
is parsed asTimes[Blank[file], Pattern[my, Blank[input]]]
$\endgroup$