I have multiple folders with this structure:
Folder Name/ tmp
Other Folder name/tmp
and so on…
Inside tmp folder I have many pdf files with this name pattern:
pdf-name-1.pdf
pdf-name-2.pdf
…. and more
I’m looking for the way to joint all pdf files inside All tmp directories with this name structure, move original PDFs to trash and rename combined pdf with pdf-name.pdf
Is there any way to do it using command line or bash script in macOS?
Than you very much.
UPDATE FOR CLARIFICATION
I need to combine all PDFs inside its own tmp folder not All PDFs inside ALL tmp folders.
Best Answer
Although you specifically asked for bash script but as a supplemental answer you could consider using the python script below. Interestingly, a part of python project (Ipython) was specifically designed to replace bash.
The thing this program demands is to hard-code the paths containing /tmp sub-folders. That can also be automated depending on how much automation you want.I won't recommend removing original pdfs unless they are occupying too much space.UPDATE: Searches for all sub-folders having name 'tmp' in the current working directory and combines all pdf files inside each of the tmp folder.