How to run macrofiles from a folder?

Hello everyone, I am interested to run 2000 macrofiles. I made a bash script, but have too many files. I can put these in a folder and compile. I do not how to compile these macros.

I tried
./example /folder/macro.mac also
./example folder/macro.mac

However, the last ones did not function. Someone who can help me I will thank a lot!

If your executable looks at argv[1] for the macro name, then you should be able to provide whatever path to the macro file you want. If your executable doesn’t support reading in macro files, that could be your problem.

// Get the pointer to the User Interface manager
G4UImanager* UImanager = G4UImanager::GetUIpointer();

// Process macro or start UI session
UImanager->ApplyCommand("/control/macroPath yourpath");
if ( ! ui ) { // batch mode
G4String command = “/control/execute “;
G4String fileName = argv[1];
} else { // interactive mode
UImanager->ApplyCommand(”/control/execute init_vis.mac”);
delete ui;

edit: that code block is from the examples, probably occurring in many of them. just added the line where it sets the path for the macro

Yup. And the “fileName” string can include whatever path you need to actual find the file. Of course, it has to be the correct path, relative to your current working directory.

1 Like

hmm, that would be too easy :face_with_monocle:

I think at some point I should learn how to code - copy paste only gets you so far…