Move out of subfolder and…

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

Moderator: Mr_Noodle

Move out of subfolder and… Wed Jan 01, 2014 1:31 pm • by snewpers
Hi

I've been reading threads where applescript is used to go up to the parent folder, but somehow it doesn't work. I've tried all sorts of this, but I'm kinda in the dark now.

I'll try to illustrate what I have working now and what I really need to get working to make it perfect:
FTP FOLDER RULES:
1 IF
Extension is .zip
DO
Unarchive

2 IF
Kind is Folder
Move to folder 'INCOMING'

--------------------

FOLDER INCOMING RULES
1 IF
KIND IS FOLDER
DO
Run rules on folder contents

2 IF
Extension is XML
DO
Rename pattern name.txt
copy to folder 'incoming_xml'



This all works fine, but now the problem is that some of the unzipped folders that went into folder INCOMING have a name that contains '_notification_'. Something like 'D12345_AAA_Notification' (that folder holds the XML).

What I REALLY need to have done is that after processing the above hazel goes back to the folder that contained the XML (e.g.. 'D12345_AAA_Notification') and if the folder name has 'notification' in it, move it to another folder. So, after that I only have folders WITHOUT notification in the 'INCOMING' folder but ALL XML's are copied.

Any help would be very appreciated!
snewpers
 
Posts: 5
Joined: Wed Jan 01, 2014 1:10 pm

Re: Move out of subfolder and… Thu Jan 02, 2014 4:20 pm • by Mr_Noodle
If you option-click the + button to add a new condition, it will create a nested condition. There, you can set the condition to target the enclosing folder which will let you move a file based on some aspect of its parent folder.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Move out of subfolder and… Thu Jan 02, 2014 5:10 pm • by snewpers
Thanks for the reply Mr.Noodle but that's not the problem.

All folders MAY contain an XML file. If there is an XML, rename it an copy the XML to another folder.
So the rule is to look into the folder and check for xml files to process.

After processing the files, go up one level, to the folder and check the filename of the folder and if it matches a pattern, move it to another location.

The thing is, I need the XML to be copied to another location BEFORE the folder containing the XML is processed for it's name.

- folder WATCH is the one with rules
-- All folder that go in here are looked into for XML's and if there is one, copy it.

So now the path is:

--> WATCH --> NEW_FOLDER --> file.xml

After that I need a rule that checks to see if NEW_FOLDER;s name matches a pattern, so one level up.

I can't get it to work, not nested, not with an AS. Every rule after the xml copy is ignored because I need the 'kind is Folder' rule. But I'm already inside the NEW_FOLDER folder so it finds nothing. There may be files in that folder that match the pattern too, so I need to set it to a 'kind is folder'.

Hope I cleared it up a tad :)

EDIT:

If I turn off the 'Run rules on folder contents' it DOES move the matching folder, but it IGNORES the 'copy xml' rule… seems like it's one OR the other, not one AND the other…
snewpers
 
Posts: 5
Joined: Wed Jan 01, 2014 1:10 pm

Re: Move out of subfolder and… Fri Jan 03, 2014 4:15 pm • by Mr_Noodle
Only the first rule matches gets run. You need to re-order the rules to take that into account. Use the preview to check that.

Also, if you want to move the folder based on its contents use the "any/all of it's sub-files" in the nested condition instead. Basically, that would mean "Match this folder if it does/does not contain files matching these conditions".
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Move out of subfolder and… Mon Jan 13, 2014 6:29 pm • by snewpers
I ended up splitting the folders up based on the folder name, prior to extracting the XML. That way I had full control, the nested rules did not work.

Thanks for the help!

:)
snewpers
 
Posts: 5
Joined: Wed Jan 01, 2014 1:10 pm


Return to Support