ukpete
Posts: 2
Joined: Mon Dec 12, 2016 10:48 am

Output file name format options needed

Tue Dec 13, 2016 4:22 am

I would find it extremely useful if certain parameters could be included in the output gcode file name. e.g. [nozzle diameter],[filament dimeter], [print quality] as a minimum.
This would help when reviewing a list of previously generated output files. This is necessary when choosing which extruder head to mount and which filament to load. (I use both 1.75mm and 3mm each with it's own extruder).
Slic3r already has this feature and It is very convenient.

brian442
Posts: 1243
Joined: Mon Nov 28, 2016 5:35 am

Re: Output file name format options needed

Tue Dec 13, 2016 5:03 am

You may already know this, but I frequently have to look back and see what settings I used for a prior print, and in my case, I need to know more than just a few settings. I typically need to check things like the machine, filament, temperatures, speeds, nozzle size, layer height, first layer settings, etc. But thankfully, it seems that S3D already includes all of the settings that were used to generate the file at the top of the gcode file as comments. So I just open the gcode file in a text editor and I have all the answers I need.

Just a quick tip in case anyone wasn't aware of this :D

AxelH
Posts: 1
Joined: Tue Jan 22, 2019 11:39 am

Re: Output file name format options needed

Tue Jan 22, 2019 11:49 am

Even if this is an old thread it showed up again and again when I tried to find a way to do basicaly the same thing so I am adding the solution I found for it.

Code: Select all

CMD /C "REN" [output_filepath] [output_filename]2.x3g
This adds a 2 in the end of all saved files and anyone using it should change it to match what they want to do and to use a file extension that thear machine use.

If you have the post processing part in the global part of the .FFF xml file you can probibly use any of the placeholders from https://community.ultimaker.com/topic/1 ... g-scripts/ etc

I have post processing set differently for differently materials so I will just write in the needed info in the comand directly. (I might move it to under the quality seting that I have nested under material)

IcanCwhatUsay
Posts: 5
Joined: Sun Apr 05, 2015 5:23 pm

Re: Output file name format options needed

Thu Oct 15, 2020 11:38 am

@ AxelH

So I put the exact code you have written in the "Additional Commands for Post Processing" field of the Scripts tab and nothing is happening. Is there something else I'm supposed to do or a different place this is supposed to go in order to get this to work?

parallyze
Posts: 193
Joined: Fri Jun 05, 2015 4:18 am

Re: Output file name format options needed

Thu Oct 15, 2020 12:49 pm

IcanCwhatUsay wrote:
Thu Oct 15, 2020 11:38 am
So I put the exact code you have written in the "Additional Commands for Post Processing" field of the Scripts tab and nothing is happening. Is there something else I'm supposed to do or a different place this is supposed to go in order to get this to work?
As far as I can tell that doesn't really work as expected when copy/pasting this... on my replicator profile it's only renaming the X3G file. On other printers (gcode only) it simply renames the .gcode file and removes the extension.

If you're saving to .gcode only and want to rename that file, this should work:

Code: Select all

cmd /c ren [output_filepath] [output_filename]_2.gcode
(Saving to "test1.gcode", file gets saved and is renamed to "test1_2.gcode" afterwards)

IcanCwhatUsay
Posts: 5
Joined: Sun Apr 05, 2015 5:23 pm

Re: Output file name format options needed

Thu Oct 15, 2020 11:19 pm

parallyze wrote:
Thu Oct 15, 2020 12:49 pm

As far as I can tell that doesn't really work as expected when copy/pasting this... on my replicator profile it's only renaming the X3G file. On other printers (gcode only) it simply renames the .gcode file and removes the extension.

If you're saving to .gcode only and want to rename that file, this should work:

Code: Select all

cmd /c ren [output_filepath] [output_filename]_2.gcode
(Saving to "test1.gcode", file gets saved and is renamed to "test1_2.gcode" afterwards)

So using this code,

Code: Select all

cmd /c ren [output_filepath] [output_filename]_2.gcode
Nothing happens when I'm saving as a gcode file. it's just StlFileName.gcode. I can tell the slicer is at least recognizing that there's text in this field because it shows up in the .gcode file properties section, but that's about it. So, I contacted support to see if there was a straight forward method since I can't seem to find any documentation on this and they suggested I use this code: (see below)

Code: Select all

{EXTENSION "insertyourprofilenamehere.gcode"}
When I do this, it treats "insertyourprofilenamehere" as part of the extension and won't show the rest of the files in the folder (which is understandable). I don't really like this solution since it doesn't get rid of the initial period so my files are then called

STLFileName.InsertYourProfileNameHere.gcode

My only goal really is to call out files based on what machine or profile I used to slice them and I would prefer it to be a prefix anyways since I can then sort by if it's a prefix. I really feel like there is a straight forward, automated way of doing this. I just can't seem to find it.

parallyze
Posts: 193
Joined: Fri Jun 05, 2015 4:18 am

Re: Output file name format options needed

Fri Oct 16, 2020 11:23 am

IcanCwhatUsay wrote:
Thu Oct 15, 2020 11:19 pm
So using this code,

Code: Select all

cmd /c ren [output_filepath] [output_filename]_2.gcode
Nothing happens when I'm saving as a gcode file. it's just StlFileName.gcode. I can tell the slicer is at least recognizing that there's text in this field because it shows up in the .gcode file properties section, but that's about it.
Is it possible there's some spaces in your path and/or filename? Then quotation marks should help:

Code: Select all

cmd /c ren "[output_filepath]" "[output_filename]_2.gcode"
Tested this with different combinations (spaces within path, filename and both), seems to work.
My only goal really is to call out files based on what machine or profile I used to slice them and I would prefer it to be a prefix anyways since I can then sort by if it's a prefix. I really feel like there is a straight forward, automated way of doing this. I just can't seem to find it.
Scripts are within a profile so instead of "_2" you could add "_machinename" to use this with different profiles.

You could add checking for different file extensions and other things. But I'd suggest doing so inside a batch/cmd file and just passing
the filename from S3D to that one. Using for-loops inside the script window is tricky because of how the "%" and quotation marks get handled...

Edit:
This is what the above line looks like in the final gcode file:

Code: Select all

;   postProcessing,cmd /c ren "[output_filepath]" "[output_filename]_2.gcode"
exactly like in the scripts window.

If this doesn't work, try something very simple to see if cmd is doing anything at all:

Code: Select all

cmd /c calc.exe
This should open up windows calculator each time you save a file.


By adding "echo" and a redirection like this (the space between " and > is important!):

Code: Select all

cmd /c echo ren "[output_filepath]" "[output_filename]_2.gcode" >c:\test\output.txt
Instead of executing the ren(ame) command it will echo the whole command to a text file. This
should now read something like this:

Code: Select all

ren "C:\Test\My Test Export.gcode" "My Test Export_2.gcode" 
I've saved the file to "C:\Test\My Test Export.gcode" and it'd be renamend to "My Test Export_2.gcode".

parallyze
Posts: 193
Joined: Fri Jun 05, 2015 4:18 am

Re: Output file name format options needed

Fri Oct 16, 2020 2:21 pm

IcanCwhatUsay wrote:
Thu Oct 15, 2020 11:19 pm
My only goal really is to call out files based on what machine or profile I used to slice them and I would prefer it to be a prefix anyways since I can then sort by if it's a prefix. I really feel like there is a straight forward, automated way of doing this. I just can't seem to find it.
Here's another possible solution if you want to rename files according to any information available in the comments on top:

Create a textfile, I'm using "filemods.cmd" in "c:\test" here.

Code: Select all

@echo off

echo Input file: "%~1%"
echo/

for /f "tokens=1,2 delims=,;" %%x in ('findstr /i "printMaterial" "%~1"') do (
  echo "printMaterial" is: %%y
  set textToAdd=_%%y
)

for /f "tokens=1,2 delims=,;" %%x in ('findstr /i "printQuality" "%~1"') do (
  echo "printQuality" is: %%y
  set textToAdd=%textToAdd%_%%y
)

echo/
echo Text to add to filename: %textToAdd%
echo/
echo on
@echo Rename command:
ren "%~1" "%~n1%textToAdd%%~x1"
@echo/
This batch/cmd requires a filename as an argument. It will then look for the strings "printMaterial" and "printQuality" inside that
file and append the information found to the filename. Here's what it looks like when used from the command line:
filemods_1.JPG
Using the script inside the post processing scripts like this:

Code: Select all

c:\test\filemods.cmd "[output_filepath]"
will rename each file saved.

This can easily be changed to the profileName or anything else inside the gcode file. Or one could copy/move files to different
locations depending on settings...

Return to “Feature Requests”