Search code examples
gnuplotdirectory

make an output directory in Gnuplot


I'm trying to save an .eps file in a folder that doesn't exist yet. I wrote the following gnuplot script:

plot [0:0.13][0:55] 'example/x_-4_U.xy'
set output 'output/x=-4.eps'
replot

The script only works if the "output" folder is already there . Can I create this folder with gnuplot?

Thanks.


Solution

  • You can use the system command:

    system "mkdir output"
    

    on Linux, I seem to remember that it is md output on Windows.

    Combined with string operators, this is rather flexible:

    dir = "output1"
    command = "mkdir " . dir
    system command
    

    works nicely.