Reputation: 1315
I've written a script that iterates all the files in a directory and plots them. The output is .pdf
. Since I pass the file names as argument, I need to change the output's extension.
For instance: when I plot file1.dat
, the output is file1.dat.pdf
. But I don't want .dat
part.
I can concatanate strings in gnuplot script but how to remove the extension(last 4 characters)?
Upvotes: 2
Views: 613
Reputation: 48420
In gnuplot you have some string function which you can use. In your case you have several options:
Pass only the basename of the file so that you can do set output file.'.pdf'; ... plot file.'.dat'
Remove the last four characters: set output file[:strlen(file)-4].'.pdf'
Search only for .dat
: set output file[:strstrt(file, '.dat')].'.pdf'
etc.
Upvotes: 2