3

This is less a direct LaTeX question than it is about compiling LaTeX.

I am using eclipse and in my project properties i set Output File = document.pdf . My demoproject compiles and outputs the File.

What i want is to define something like document_$DATE$_$VERSION$.pdf .

I want eclipse to generate the Date and i want my demoproject to set the Version.

\documentclass{article}
\Version{A}
\begin{document}
This is my document.
\end{document}

How would i do something like that?

1
+50

I can provide an indirect answer via arara. :)

This rule might do exactly what you want (untested on Windows, but I believe it works):

!config
identifier: renamer
name: Renamer
commands:
- <arara> @{isWindows("cmd /c rename", "mv")} "@{getBasename(file)}.pdf" "@{getBasename(file)}_@{date.concat(version)}.pdf"
arguments:
- identifier: date
  default: <arara> @{(new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new java.util.Date())}
- identifier: version
  flag: <arara> @{"_".concat(parameters.version)}

I opted for the yyyy-MM-dd pattern, but this can be easily changed. :) The idea here is:

  1. Get foo.pdf.
  2. Get the current date (e.g, 2014-03-26).
  3. Append the date to the filename.
  4. If any version provided via directive, append it as well.
  5. ???
  6. Profit. :)

A quick example:

% arara: pdftex
% arara: renamer
Hello world!
\bye

Running arara:

paulo@alexandria paulo$ ls
vtest.tex
paulo@alexandria paulo$ arara vtest.tex 
  __ _ _ __ __ _ _ __ __ _ 
 / _` | '__/ _` | '__/ _` |
| (_| | | | (_| | | | (_| |
 \__,_|_|  \__,_|_|  \__,_|

Running PDFTeX... SUCCESS
Running Renamer... SUCCESS
paulo@alexandria paulo$ ls
vtest_2014-03-26.pdf  vtest.log  vtest.tex

If I want to append a version ID:

% arara: pdftex
% arara: renamer: { version: 'draft' }
Hello world!
\bye

And now:

paulo@alexandria paulo$ arara vtest.tex 
  __ _ _ __ __ _ _ __ __ _ 
 / _` | '__/ _` | '__/ _` |
| (_| | | | (_| | | | (_| |
 \__,_|_|  \__,_|_|  \__,_|

Running PDFTeX... SUCCESS
Running Renamer... SUCCESS
paulo@alexandria paulo$ ls
vtest_2014-03-26_draft.pdf  vtest_2014-03-26.pdf  vtest.log  vtest.tex

There we go! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.