Page 1 of 1

copying pdf & appending a folder's comment to the pdf's name

PostPosted: Thu May 05, 2016 10:55 am
by tobefirst
I'm hoping someone can help me write a rule.

I have a few thousand project folders that have comments on them consisting of a contact's name and project number. For instance, one folder might be called "Hamburger Flyer 05.05.16" and have a comment of "Bob 3-1111".

Inside that folder are the project files – usually an Adobe InDesign file (Hamburger Flyer.indd), some .jpgs (DSC_0001.jpg and DSC_0012.jpg), and a .pdf (Hamburger Flyer.pdf).

On that .pdf somewhere is a text box with that same project number (3-1111) all by itself.

What I would like to do is to copy each .pdf (again, I have thousands) to a designated folder, and append the project number to the file name. So, for instance, I'd like to copy Hamburger Flyer.pdf to a new folder I've created called "Finals" and change the name of the .pdf to either "Bob 3-1111 Hamburger Flyer.pdf" or "3-1111 Hamburger Flyer". (I don't care which...the project number is the important part.) So, I can grab the project number either from the enclosing folder or from the content of the .pdf.

I'd like to be able to set this rule up so that it goes inside of all containing folders (2016 > May > Hamburger Flyer 05.05.16) so I don't have to do each folder individually. For the life of me, I can't figure out just how to get this to work. Any pointers?

Re: copying pdf & appending a folder's comment to the pdf's

PostPosted: Thu May 05, 2016 1:32 pm
by Mr_Noodle
Check out this article about going into subfolders: https://www.noodlesoft.com/kb/going-into-subfolders/

Read it carefully. If you modify that rule, chances are very high that you are doing it wrong.

That will get Hazel to go into subfolders. Now, to process the pdf files. First read this article: https://www.noodlesoft.com/kb/how-to-cr ... onditions/

In this case, you want to match PDFs. You also want to create a nested condition. There, set the condition to "the enclosing folder". Now add a condition under that like "Comment matches (•parent comment)", where (•parent comment) is set up to match anything (if you don't know anything about match patterns, search for it in the in-app help).

Now you have the parent folder's name contained in the (•parent comment) attribute. You can use that in the Rename action to get the comment in there.

You'll have to tweak the above but that should cover all the pieces you'll need.

Re: copying pdf & appending a folder's comment to the pdf's

PostPosted: Thu May 05, 2016 2:27 pm
by tobefirst
Thanks for your help. I think I'm getting somewhere, but I'm not quite there. I have two rules:

1. Go into folders
If all of the following conditions are met
Kind is Folder
Do the following to the matched file or folder:
Run rules on folder contents

2. Copy PDF
If all of the following conditions are met
Kind is PDF
if any of the following conditions are met for its enclosing folder
Comment matches 3-[digit][digit][digit][digit]
Do the following to the matched file or folder:
Copy to folder: pdfs
Rename with pattern: [comment] [name][extension]

What am I messing up? Any idea? I appreciate you pointing me in the right direction and helping me learn the hows and whys in this.

Re: copying pdf & appending a folder's comment to the pdf's

PostPosted: Thu May 05, 2016 4:09 pm
by Mr_Noodle
Try going through the troubleshooting guide here: https://www.noodlesoft.com/kb/hazel-tro ... ing-guide/

Report back at which step it seems things aren't panning out.

Re: copying pdf & appending a folder's comment to the pdf's

PostPosted: Thu May 05, 2016 4:24 pm
by tobefirst
Okay, I've adjusted the rules so that the folders are being served by "Go into folders" and the .pdf files are being served by "Copy PDF." It copies the file and renames it " [name][extension]" (adding a space before the file name). It doesn't seem to *copy* the comment from the enclosing folder to drop into the filename of the .pdf.

Here are my rules, slightly edited from the previous:

1. Go into folders
If all of the following conditions are met
Kind is Folder
Do the following to the matched file or folder:
Run rules on folder contents

2. Copy PDF
If all of the following conditions are met
Kind is PDF
if any of the following conditions are met for its enclosing folder
Comment matches [abc] [digit]-[digit][digit][digit][digit]
Do the following to the matched file or folder:
Copy to folder: pdfs
Rename with pattern: [comment] [name][extension]

I appreciate all the help! Thank you so much!

Re: copying pdf & appending a folder's comment to the pdf's

PostPosted: Thu May 05, 2016 4:59 pm
by Mr_Noodle
Is the file matching the second rule? If the comment is blank, then I'm not seeing how it would pass the "comment matches" condition.

Re: copying pdf & appending a folder's comment to the pdf's

PostPosted: Fri May 06, 2016 8:35 am
by tobefirst
I guess not. If I click on Preview of the Copy PDF rule, it says "Not Matched: Kind - Folder."

I have a folder structure like this:
2016 1st Quarter > Hamburger Flyer 05.05.16 > (working files - .indd, .jpg, .pdf)

I tried having the two rules applied to the 2016 1st Quarter and that didn't work. And I tried having them applied to the Hamburger Flyer 05.05.16 folder and that didn't work either. The Copy PDF rule fails both times, saying the above. I don't understand why.

Re: copying pdf & appending a folder's comment to the pdf's

PostPosted: Fri May 06, 2016 12:40 pm
by Mr_Noodle
The second rule should be matching a PDF file so you need to have the preview check against that, not against a folder.

Re: copying pdf & appending a folder's comment to the pdf's

PostPosted: Fri May 06, 2016 1:20 pm
by tobefirst
When I check Copy PDF against a .pdf, I get green checks on all three lines. However, it still won't append the project number ("3-1111" for instance) to the file it copies into the new folder.

Re: copying pdf & appending a folder's comment to the pdf's

PostPosted: Fri May 06, 2016 4:49 pm
by Mr_Noodle
How about the status interface (the "eye" button)? Does the PDF still match the rule there? If not, what do you see instead? Is there an error?

Re: copying pdf & appending a folder's comment to the pdf's

PostPosted: Mon May 09, 2016 10:05 am
by tobefirst
The folder matches the "Go into folders" rule and when I click the triangle on each folder, the .pdfs inside match the "Copy PDF" rule. I don't think I'm copying the comment from the folder and pasting it to the .pdf correctly is my guess, but I'm at a loss as to how to fix that.

Re: copying pdf & appending a folder's comment to the pdf's

PostPosted: Mon May 09, 2016 10:41 am
by Mr_Noodle
I suggest you email your rules in. Click on "Contact Support" in Hazel's Info section and send them over so I can take a look at them.

Re: copying pdf & appending a folder's comment to the pdf's

PostPosted: Mon May 09, 2016 12:30 pm
by tobefirst
Done. Thank you. Let me know if I can do anything else to help! I very much appreciate your assistance.