Renaming based on nested folders

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

Moderator: Mr_Noodle

Renaming based on nested folders Tue Nov 04, 2014 2:13 am • by 3dp
Pardon if this is covered else where but I have a specific need and can't crack it.
Goal:
• I need to have a single folder with 3 subfolders inside it.
• I need to rename any file placed into any of those subfolders to have a specific name added based on the subfolder in which it is placed.

Example:
Main folder
Subfolder 1 - If a file is placed into Subfolder 1, I need to have that filename amended to add "-sub1".
Subfolder 2 - If a file is placed into Subfolder 2, I need to have that filename amended to add "-sub2".
Subfolder 3 - If a file is placed into Subfolder 3, I need to have that filename amended to add "-sub3".

Can I do this with the Main Folder watched and sub rules under that? Or will I have to set up each subfolder as a watched folder. Just trying to keep the watched folder list manageable and make it as streamlined as possible.
Thanks for any help.
3dp
 
Posts: 3
Joined: Tue Nov 04, 2014 1:53 am

Re: Renaming based on nested folders Tue Nov 04, 2014 1:11 pm • by Mr_Noodle
The part that's unclear is can you derive the text to add to the filename based on the name of the subfolder it's in? If not, then you may have to have a specific rule for each case, or use the "Replace text" option with a bunch of entries.
Mr_Noodle
Site Admin
 
Posts: 11866
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Renaming based on nested folders Tue Nov 04, 2014 4:44 pm • by 3dp
Hi, Thanks for the reply.
No, I don't want to derive the addition to the filename from the subfolder. I really only want to add a constant fixed addition to the new filename when it's added to the folder.

If for each PDF dropped into subfolder 1, I want it to append "-sub1" (or other text) to the end of the filename before the .PDF extension. For each PDF dropped into subfolder 2 I want it to append "-sub2" (or other text) to the end of the filename before the .PDF extension. etc.

I can do this with individual watched folders for each subfolder but thought it would be neater and more streamlined to be able to nest rules under the main watched folder were all the subfolders sit.

I just can't figure out how to do that.
Thanks!
3dp
 
Posts: 3
Joined: Tue Nov 04, 2014 1:53 am

Re: Renaming based on nested folders Tue Nov 04, 2014 4:49 pm • by Mr_Noodle
If you want to process files in subfolders, read the sticky article at the top of this forum CAREFULLY. In particular, do not add any logic to the rule there unless you actually understand it. If not, then do not touch it.

You can fit it into a single rule if you use text replacement then, assuming I'm understanding what you are trying to do. You would need a rule like:
Code: Select all
    If (all) match
        If (all) match for (the enclosing folder)
            Name matches (•parent name)
        Kind is PDF
    Do
        Rename (name)(•parent name)


There are a few tricky things to note:
[list]
[*] To get the nested condition, hold down option while clicking the + button
[*] •parent name is a custom text attribute that you define. Define it as matching (anything)
[*] When using the •parent name attribute in your rename action, click on it and select "Replace text". There you can set up a table of replacements based on the parent folder's name.

You'll have to tweak this but hopefully it gives you the general idea of what you need to do.
Mr_Noodle
Site Admin
 
Posts: 11866
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Renaming based on nested folders Tue Nov 04, 2014 10:39 pm • by 3dp
Thanks for the direction. I'll apply the rule and re-read the sticky article again. Hopefully I can get the results I'm looking for. Thanks again.
3dp
 
Posts: 3
Joined: Tue Nov 04, 2014 1:53 am


Return to Support