Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
4  
Sounds more like a job for a python script than for texmaker. Recursively search the folder tree for files named *.pdf and copy them to the target folder. Perhaps it's even possible to do directly in Windows Explorer/Finder/whatever file manager your OS provides. –  Tomas Lycken Nov 22 '11 at 20:01
    
Are you referring to organizing your TeX working folder(s), or are you referring to moving PDFs to a specific folder (immediately) after compiling? –  Werner Nov 22 '11 at 20:06
    
Actaully I do not care wheter the files are moved imediately after compiling or not. I just want to To have pdfs automaticaly store in two locations, based on which folders the tex files lie in. If If compiling document from folder y, output pdf to foldeer y and z. –  N3buchadnezzar Nov 22 '11 at 21:07
    
Are you working on Linux, Windows or Mac? –  adn Nov 30 '11 at 4:55
    
Windows 7. 64bit –  N3buchadnezzar Nov 30 '11 at 6:04

3 Answers 3

up vote 6 down vote accepted
+50

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%"
:: Return to original
cd "%cur%"
:clean
del "%exf%"

GOTO end
:usage
ECHO Usage: %0 source destination
ECHO If destination does not exist, it will be created.
ECHO.
:end
share|improve this answer

I'd like to add another answer for the sake of completeness. I'm not a fan of the following procedure, but anyway. :)

Another way is to add a watcher to track changes in your folders. A watcher is a tool that continuously monitors one or more folders and subfolders for files changes. It might also trigger custom actions.

There are some apps out there for this especific purpose, but I couldn't find a proper one. Most of the are paid, others are freeware/opensource. File Watcher Utilities seems to be a nice one.

That said, my answer consists of:

  1. Set the project structure, e.g, C:\paulo\sources.
  2. Create an output folder, e.g, C:\paulo\output.
  3. Add a watcher to the corresponding folders.

I wrote the following Ruby code to watch my sources folder and look for pdf files. When found, the file is copied to the output folder.

Note: Sorry for the bad Ruby code, I wrote it in a hurry.

require 'rubygems'
require 'fssm'
require 'fileutils'

FSSM.monitor("C:/paulo/sources","**/*.pdf") do
    update do |b, r|
        FileUtils.cp r, "C:/paulo/output/#{r}"
    end

    create do |b, r|
        FileUtils.cp r, "C:/paulo/output/#{r}"
    end
end

Then I put this script to run in my terminal.

Every time a pdf file is created/updated, a copy is automatically sent to the output folder (of course, the script must be running in the background in order to keep track of files changes). No need of running additional steps. :)

share|improve this answer

I have to deal with such a situation quite often in a process called "legal due diligence": I get tons of pdfs, organised in folders and it is critical to read them all and not to miss one.

What I do is:

  1. Using something like the unix-command "ls" to print the whole folder structure recursivly into a text file.
  2. I start a *.tex-file in C:\exam and add this text as first chapter. It contains the names of all subfolders and files.
  3. Now I add the names of all subfolders as chapter names.
  4. Last step: heavy use of the package pdfpages: for each pdf I add a line \includepdf[pages=-]{foldername/name-of-the-file.pdf}

pdftex compiles one large pdf of all, usually I add headlines and pagenumbers using scrpage2.

Just yesterday I compiled a pdf of 978 page, which took some minutes. That was the funniest part, by the way. Now I have to read it all . . .

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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