P
P
Pavel Ivanov2018-09-22 11:14:20
linux
Pavel Ivanov, 2018-09-22 11:14:20

How to process sets of files recursively?

We have a folder and file structure:

<GROUP>
|-<DOCTYPE>
|--<STUDENT>
|---<FILENAME>-1.jpg
|---<FILENAME>-2.jpg
|---<FILENAME>-N.jpg
|---<OTHERNAME>-1.jpg
|---<OTHERNAME>-N.jpg

It is necessary to make sure that in each folder (and there are about 1500+ of them) the files FILENAME-1.jpg, FILENAME-2.jpg, FILENAME-N.jpg (hereinafter referred to as page scans) are glued into PDF.
There is imagemagick on the server, so I'm considering the option with convert.
If you do everything in each folder by hand, then everything looks great, although sometimes it confuses pages due to find's inability to sort the output:
find . -type f "FILENAME-*.jpg" -exec convert {} FILENAME.pdf \;

But with a large number of folders, it becomes somehow sad.
Tell me, please, a solution that will glue the scans of pages without sorting flaws and with a recursive bypass of folders.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Mirilaczvili, 2018-09-22
@paulvonlecter

1. If I'm not mistaken, the set of files is converted into 1 pdf with the command
convert filename-*.jpg out.pdf
2. For the pagination to be correct, the files must be named with leading zeros, otherwise pages 1, 10, 2, 3, .. will be processed. It
remains to think about how to group files by names , , ...

K
ky0, 2018-09-22
@ky0

You can also sort the output findof `a and only then set it on the list convert. For example, a bunch find | sort | xargs convert, but in general there are many options.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question