Consider the directory recepis

├── bechamel
│   ├── bechamel.aux
│   ├── bechamel.log
│   ├── bechamel.pdf
│   └── bechamel.tex
├── bolognese
│   ├── bolognese.aux
│   ├── bolognese.log
│   ├── bolognese.pdf
│   └── bolognese.tex
├── Brownies
│   ├── brownies.aux
│   ├── brownies.log
│   ├── brownies.pdf
│   └── brownies.tex

As you can see I am using Latex to write my recipes. I would like to copy all the pdf files to a separate directory every time I compile a tex file to a pdf or a new pdf is created. Namely pdf files should then to copied to a directory recipyPdfCollection

I am using the OS Ubuntu so I would guess a bash would be needed. It would be good if some notes could be added so that I could understand the solution. I tried the command

find ./  -iname '*.pdf' -exec cp -t ./pdfs/  {} +

which copies all files but it seems tedious to run this command every time there is a change therefore automated script would be great.

  • General hint to consider with almost any solution: if inside a single Linux filesystem, do not copy, create hardlinks instead. – Kamil Maciorowski Aug 28 '17 at 14:39
  • 1
    Simplest way is to change whatever you use to compile your Latex to add a copy of the output the the target directory. Otherwise you can use cp --no-clobber .... – xenoid Aug 28 '17 at 16:51

Your Answer

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

Browse other questions tagged or ask your own question.