Save All Graphs As Graphics Files
hrodstein
// SaveAllGraphsAsGraphicsFiles(pathName, extension, visibleOnly, format, bitmapRes)
// NOTE: This overwrites existing files with the same name.
// Example:
// SaveAllGraphsAsGraphicsFiles("home", ".png", 1, -5, 288)
Function SaveAllGraphsAsGraphicsFiles(pathName, extension, visibleOnly, format, bitmapRes)
String pathName // Name of Igor symbolic path pointing to folder where graphics should be saved.
String extension // Extension for file name, e.g., ".tif", ".pdf", ".png" . . .
Variable visibleOnly // 1 to save only visible graphs, 0 to save visible and hidden graphs.
Variable format // For SavePICT /E flag. See SavePICT documentation.
Variable bitmapRes // For SavePICT /RES flag (e.g., 288 for 288 dpi).
Variable index = 0
do
String graphName = WinName(index, 1, visibleOnly)
if (strlen(graphName) == 0)
break // All done
endif
String fileName = graphName + extension
SavePICT /N=$graphName /O /P=$pathName /E=(format) /RES=(bitmapRes) as fileName
index += 1
while(1)
End
// NOTE: This overwrites existing files with the same name.
// Example:
// SaveAllGraphsAsGraphicsFiles("home", ".png", 1, -5, 288)
Function SaveAllGraphsAsGraphicsFiles(pathName, extension, visibleOnly, format, bitmapRes)
String pathName // Name of Igor symbolic path pointing to folder where graphics should be saved.
String extension // Extension for file name, e.g., ".tif", ".pdf", ".png" . . .
Variable visibleOnly // 1 to save only visible graphs, 0 to save visible and hidden graphs.
Variable format // For SavePICT /E flag. See SavePICT documentation.
Variable bitmapRes // For SavePICT /RES flag (e.g., 288 for 288 dpi).
Variable index = 0
do
String graphName = WinName(index, 1, visibleOnly)
if (strlen(graphName) == 0)
break // All done
endif
String fileName = graphName + extension
SavePICT /N=$graphName /O /P=$pathName /E=(format) /RES=(bitmapRes) as fileName
index += 1
while(1)
End
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
Works great. But is there a way that the save dialog box doesn't show up every time ?
April 3, 2019 at 04:09 pm - Permalink
You will get a dialog box if you have no home path but use "home" as the first parameter. The home path is not defined in an untitled experiment.
You need to provide a valid symbolic path name as the first parameter. Execute this for details:
DisplayHelpTopic "Symbolic Paths"
April 3, 2019 at 06:48 pm - Permalink
This is what I did. Made a NewPath inside the SaveAllGraphsAsGraphicsFiles function and stored the information in pathName. But If I have 8 graphs, the save dialogbox pops up 8 times and asks me to save, instead of saving everything in the folder all at once.
String pathName // Name of Igor symbolic path pointing to folder where graphics should be saved.
String extension = ".jpeg" // Extension for file name, e.g., ".tif", ".pdf", ".png" . . .
Variable visibleOnly = 1 // 1 to save only visible graphs, 0 to save visible and hidden graphs.
Variable format = -6 // For SavePICT /E flag. See SavePICT documentation.
Variable bitmapRes = 288 // For SavePICT /RES flag (e.g., 288 for 288 dpi).
NewPath/O/M="Select the folder to Save all the Graphs" pathName
PathInfo/S pathName
Variable index = 0
do
String graphName = WinName(index, 1, visibleOnly)
if (strlen(graphName) == 0)
break // All done
endif
String fileName = graphName + extension
SavePICT /N=$graphName /O /P=$pathName /E=(format) /RES=(bitmapRes) as fileName
index += 1
while(1)
End
April 4, 2019 at 08:23 am - Permalink
I think you need to remove the "$" from the SavePict line. PathName is not string variable but a path name.
use /P=pathname instead of /P=$pathname.
Andy
April 4, 2019 at 08:41 am - Permalink
In reply to I think you need to remove… by hegedus
Andy,
Well of course it was that simple. Working perfectly now. Thank you.
@hrodstein thank you for the code.
April 4, 2019 at 08:47 am - Permalink