Page 1 of 1

Merge pdfs in subfolder

PostPosted: Wed Feb 24, 2016 9:30 am
by vloryan
Hi there, I know the "How to get Hazel to go into subfolders" post, but that did not help to solve my problem.

My main folder is called "X", pdfs in that folder will be sorted in a subfolder named like a part of the filename.
The pdf files in that subfolder should merge to one pdf-file using "RUN SHELL SCRIPT"

Code: Select all
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combined.pdf -dBATCH *.pdf


Well, the "combined.pdf" is somehow stored in the main folder "X", not in the subfolder :( And the combined.pdf is empty by the way. Any idea how I get this thing running correctly?

"Run on folder contents" is my top rule.

Thanks for your help!

Re: Merge pdfs in subfolder

PostPosted: Wed Feb 24, 2016 11:18 am
by Mr_Noodle
I don't think you want to go into subfolders. Instead it might be better to have the rule match the subfolder containing the PDFs and run the script on that. You would need to modify the script to take that into account. Also, you shouldn't assume the current working directory. Instead you should base things off of the first argument ($1) sent in which is the full path of the folder/fille that matched the rule.

Re: Merge pdfs in subfolder

PostPosted: Wed Feb 24, 2016 2:21 pm
by vloryan
thanks for your help, but i don't get it :) don't know what you mean.

Re: Merge pdfs in subfolder

PostPosted: Wed Feb 24, 2016 3:40 pm
by Mr_Noodle
Rules are meant to match one file or folder, depending on how you set up the conditions. Since you want the script to run on a bunch of files, it makes more sense to have the rule match the folder containing those files and operate on it. By doing that, your script will have to be modified as well to take that into account. The path to the folder will be sent in as an argument. From that you need to adjust the paths in your script.