# [Tex/LaTex] Gathering pdf outputs multiple places (Texmaker)

pdftexmaker

I have a lot of different files stored in a lot of different folders.

My ultimate goal would be to get all the final PDF files copied or stored automatically to another folder, so that I could have a single folder containing all the PDF files from my various folders.

So far I have a directory looking like this

C:Exams
\Subject 1
Exam A.pdf
Exam B.pdf
\Subject 2
Exam C.pdf
Exam D.pdf
\Subject 3
Exam E.pdf
Exam F.pdf
...


Now, what I would like is a new folder, containing all of these PDF files. Is this possible?

I also have other folders, such as notes and so on. So it is not preferable that Texmaker or some other program blindly places all of the PDF outputs from Texmaker in a single folder.

The ultimate goal would be an alternative script or program, that checks through the exam folder for PDFs and copies them to the chosen folder. Alas, I have no experience customizing Texmaker, or using any programming language whatsoever.

I made a little script using the built in tools of Windows, so you don't have to install a thing. It is basically recursively scanning the source directory for pdf files and then copying them in the destination folder.

I work with TeXStudio, that is a different version of Texmaker. However, I think that you can run the script within the IDE in the same way. In the quickbuild part there should be an option for a user command there you can write your own compilation, for example for pdflatex:

pdflatex -shell-escape -synctex=1 -interaction=nonstopmode %.tex  | tmx://internal-pdf-viewer | "C:\LaTeX Projects\move-pdf.bat" . pdfs


In this case, you need the absolute path of the script, and also you will need to input the directories.

To execute the script manually, you need to call it in a command line: move-pdf.bat source destination (assuming that you named the script move-pdf.bat). For example if you want to run it in your current directory just execute: move-pdf.bat . pdfs. If you want to run it in several directories it is a good idea to put it in a place where your system can find it, or add the path where you place the script to the system variables. Else, you can place it in every directory. Moreover, if you want to avoid passing the parameters all the time and just to execute for a default source and destination, put those paths in the two variables src and dst.

@ECHO off
IF [%1]==[] GOTO usage
IF [%2]==[] GOTO usage
SET src=%~f1
SET dst=%~f2
IF EXIST "%dst%" GOTO process
MKDIR "%dst%"
:process
ECHO Copying from "%src%" to "%dst%"
:: Exclude file. Exclude the same directory in the case that destination is a subdir of source.
SET exf=%TEMP%\%~n0-exclude.txt
echo %dst% > %exf%
:: Move to source
SET cur=cd
cd "%src%"
:: Copy files recursively (/S), and only newer than destination (/D), automatically (/Y).
FOR /R %%G IN (*.pdf) DO XCOPY /S /D /Y /EXCLUDE:%exf% "%%G" "%dst%"