I want to automatically make a copy of the finalised PDF in a new directory once it is compiled.
As part of my workflow, each article (of my thesis) (and the associated graphics) is stored in its own directory. I then import each file into a master file as a combined thesis.
I already do this with the tex file itself (make a daily backup).
I have the following code at the start of each article tex file (which basically copies the existing tex file to a backup directory and renames it with today's date so I have a history of tex files):
\immediate\write18{mkdir \currfiledir backup}
\immediate\write18{cp '\currfiledir \currfilename' '\currfiledir backup/\currfilebase\string_\the\year-\the\month-\the\day .\currfileext'}
I want to have similar code that copies the finalised PDF file from the master directory into the directory of each article. Something like this (but this didn't work).
\immediate\write18{cp \jobname.pdf \currfiledir\currfilebase.pdf}
Thanks in advance
\write18to run pdflatex directly after you execute the lines above. Alternatively, you could use\write18to copy the PDF file in addition to the tex file.This said, I think you would be much better off using a version control program to do this properly. I highly recommend git. There is a bit of a learning curve but it will keep track of your daily snap shots without you having to keep all these old files lying around.
– Nov 03 '14 at 13:04-output-directory=DIR use existing DIR as the directory to write files in– David Carlisle Nov 03 '14 at 13:08\write18to move the PDF file, because the PDF file is finalized when executing\end, which comes later than any\writein the input. – egreg Nov 03 '14 at 14:08makeand your choice of scripting languages and version control systems. This is what they're designed for. Will make a quick example of how this could be accomplished. – Mike Renfro Nov 03 '14 at 15:25gitwork in this case? – James Nov 03 '14 at 17:06ln -s) for this. – alfC Nov 03 '14 at 17:42