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

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

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?
tobefirst
 
Posts: 7
Joined: Thu Feb 05, 2015 5:19 pm

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.
Mr_Noodle
Site Admin
 
Posts: 11951
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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.
tobefirst
 
Posts: 7
Joined: Thu Feb 05, 2015 5:19 pm

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.
Mr_Noodle
Site Admin
 
Posts: 11951
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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!
tobefirst
 
Posts: 7
Joined: Thu Feb 05, 2015 5:19 pm

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.
Mr_Noodle
Site Admin
 
Posts: 11951
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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.
tobefirst
 
Posts: 7
Joined: Thu Feb 05, 2015 5:19 pm

The second rule should be matching a PDF file so you need to have the preview check against that, not against a folder.
Mr_Noodle
Site Admin
 
Posts: 11951
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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.
tobefirst
 
Posts: 7
Joined: Thu Feb 05, 2015 5:19 pm

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?
Mr_Noodle
Site Admin
 
Posts: 11951
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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.
tobefirst
 
Posts: 7
Joined: Thu Feb 05, 2015 5:19 pm

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.
Mr_Noodle
Site Admin
 
Posts: 11951
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Done. Thank you. Let me know if I can do anything else to help! I very much appreciate your assistance.
tobefirst
 
Posts: 7
Joined: Thu Feb 05, 2015 5:19 pm


Return to Support