padawan
padawan

Reputation: 1315

Changing the file extension to .pdf

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

Answers (1)

Christoph
Christoph

Reputation: 48420

In gnuplot you have some string function which you can use. In your case you have several options:

  1. Pass only the basename of the file so that you can do set output file.'.pdf'; ... plot file.'.dat'

  2. Remove the last four characters: set output file[:strlen(file)-4].'.pdf'

  3. Search only for .dat: set output file[:strstrt(file, '.dat')].'.pdf'

etc.

Upvotes: 2

Related Questions