How to sort G-code on SD card based on material (ABS|PLA|SBS)?

I have various G-code files stored at SDCard attached to my Prusa i3 MK2S printer. They are either for ABS, PLA or SBS. The more files I had on the SD card, the more I was running into trouble of finding for which material is which G-code.

To tackle the situation I created folders ABS, PLA and SBS and put new files into those directories.

Is there any better method of finding, backwards from G-code, which material settings were intended to be used?

If so, is there a way to read temperature settings from G-code by Prusa i3 firmware without printing the actual model?

• Not an answer, but sort of related and a good idea: Best Practices - Labeling GCode Files. Use a filename format such as {Machine+State}_{FileName}_{YYYYMMDD-TTTT}_{FileID}.gcode, for example, UM2+PLA8_NozzleMag_20160911-1520_ym9450.gcode Jun 4 '18 at 20:04

Good question as I also ran into some files not remembering for which purpose or which material I printed these. The online G-code visualizers do not display the temperature or the correct filament width, so basically that won't help you (unless you modify the open source programs...). Reading from firmware would not be possible without adding a new feature, as far as I know, this is not implemented in Marlin Firmware or in Prusa firmware (which is based on Marlin).

When using a printer server like OctoPrint, you can store your G-code files in a folder structure that you can define yourself; so basically create a directory structure based on the material type, brand, etc.

However, it is relatively easy to write a small program in Python to read a file and interpret the lines (even if you're not a programmer). There are lots of tutorials and examples to find to open files read the file e.g. line by line and detect strings to identify the settings for G-codes M104/M109 (hot end temperature) and M140/M190 (bed temperature). Usually you slice your models with a specific set of bed and hot end temperature (which you know), so basically you can find out which material was meant to be printed with the G-code file. You could even let the program sort the files for you by moving them into separate folders.

I'll add it to my list of things I'd like to do some rainy day! :)

Note that some printers use different, or even custom G-codes to control bed temperature; e.g. when reading Ultimaker 3 G-code files you cannot see the bed temperature!

• You could also add comment line to the generated GCode, usually it begins with ; symbol. The comment can be inserted in slicer as a startcode. Jun 4 '18 at 11:59
• @jnovacho Good point you raise, but if you have never done that, you are stuck with the files you have. It is a good idea to insert a comment based on material settings in new files!
– 0scar
Jun 4 '18 at 12:31