
Igor Pro 7 Macro: Batch Save All Graphs as PNGs

I’ve seen many different scripts shared for saving graphs from the Procedure window in Igor Pro, and I wanted to create a more streamlined and reusable version. So I refined them and packaged everything into a simple macro you can easily add to your Igor Pro setup.
This macro is mostly based on the procedure introduced by Tony Withers, with a few improvements and refinements for clarity and ease of use.
I developed and tested this on Igor Pro 7 for Windows, but it might work on other versions as well; feel free to try it and let me know!
What It Does:
This macro allows you to save all open graphs at once as .png
files in a subfolder called Graphs
located in the same directory as your .pxp
file.
There are two functions you can use:
-
SaveAllGraphsN()
— Saves graphs using their window names. (Will override files if names repeat.) -
SaveAllGraphsT()
— Saves graphs using their titles. (Will prompt for a new name if duplicate titles are found.)
Usage Instructions:
-
Open the Procedure Window in Igor Pro.
-
Paste the following code.
-
Compile it.
-
Or: Save it as an
.ipf
file and place it in:
This PC\Documents\WaveMetrics\Igor Pro 7 User Files\Igor Procedures
To quickly access that folder, go to Help > Show Igor Pro User Files inside Igor.
Once it’s installed, simply run one of the commands mentioned, in the Igor command line.
code:
// Procedure 1: // Save graphs using their window "Name" // WARNING: This will override files with the same name function SaveAllGraphsN() int NGraphs, i string graphList, currWindow graphList = WinList("*", ";", "WIN:1") NGraphs = ItemsInList(graphList) PathInfo home NewPath/C/O/Q graphs, S_path + "graphs:" for (i = 0; i < NGraphs; i += 1) currWindow = StringFromList(i, graphList) GetWindow $currWindow, wtitle SavePICT/O/E=-5/P=graphs/WIN=$currWindow as currWindow + ".png" endfor end // Procedure 2: // Save graphs using their "Title" // WARNING: Make sure your titles don’t contain "/" or parentheses // If you're sure there are no duplicate titles, you can add \O to the SavePICT line to override function SaveAllGraphsT() int NGraphs, i string graphList, currWindow graphList = WinList("*", ";", "WIN:1") NGraphs = ItemsInList(graphList) PathInfo home NewPath/C/O/Q graphs, S_path + "graphs:" for (i = 0; i < NGraphs; i += 1) currWindow = StringFromList(i, graphList) GetWindow $currWindow, wtitle SavePICT/E=-5/P=graphs/WIN=$currWindow as CleanUpName(s_value, 1) + ".png" endfor end