5

Working with %pdflatex, each pdf file has the name of the .tex file from which it is compiled. For the case of writing CVs, it happens that the CV is updated each month or each week periodically.

Is there any way to name the pdf file in the format of the something like enthusiasticCV240915.pdf?

I mean, the process of naming of the pdf outputs be like this:

  • If the pdf is edited on different days, the previous pdf files which are produced on the other days are kept in the .tex folder. So, the user will have a series of his previous CVs which are named regarding the date of the day they are edited and produced on. So, when he opens the folder, he has a list of his previous and updated CVs all of which are date separated by means of the systematic file naming.

  • If the pdf is produced on the same day on which he has run and edited many times, only one file will remain in the folder with the name of that day, because the pdf file has the same name as the pdf file which is produced on the same day. I mean, each day, the user will only have one pdf file output and if he runs his tex file multiple times in the same day, he will only have one pdf file output at the end of that day with the date of that day.

I have read some questions about version control of tex files but those are not covering my question. Also, I have no idea how the MWE should be like for my question, so sorry if it is not included. Also, I am using a windows operating system.

  • What operating system are you using? I believe this needs support from outside of pure TeX or LaTeX. If you don't like using a version control system which would be the best to track changes and to re-produce any previous state, the next-best solution is to rename the PDF after compilation to the desired name. – Christian Lindig Sep 24 '15 at 7:41
  • @ChristianLindig I am using a windows os. – Enthusiastic Engineer Sep 24 '15 at 7:58
5

Setting the job name

Option --jobname can be used to set the name of the job including the .pdf, .log or .aux files. The date can be automatically generated by command date in Linux:

$ pdflatex --jobname enthusiasticCV`date +%d%m%y` enthusiasticCV.tex

On Windows the date in the name can be given manually, example for MiKTeX:

pdflatex --job-name enthusiaticCV240915 enthusiasticCV.tex

Batch script written by TeX

The TeX run can write a batch script for the renaming of the output file, which is called afterwards, example for Windows:

\makeatletter
\newwrite\batch
\immediate\openout\batch=\jobname-rename.txt
\immediate\write\batch{@echo off}
\immediate\write\batch{copy \jobname.pdf \jobname
  \two@digits\day
  \two@digits\month
  \two@digits{\numexpr\year-2000\relax}%
  .pdf%
}
\immediate\closeout\batch
\makeatother

A .txt file is written instead of a .bat file to avoid the security issue, that the writing of .bat files might not be allowed. Calling sequence is:

pdflatex enthusiasticCV
move enthusiaticCV-rename.txt enthusiaticCV-rename.bat
enthusiasticCV-rename.bat

Of course, this can be put in another batch file to ease the calling.

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.