Page 1 of 1

Complex nested folder multi-type file moving/trashing

PostPosted: Tue Jun 22, 2021 11:16 am
by sfritz313
Hi there- I have Hazel monitoring my Downloads folder for compressed files. When it detects a .zip, it decompresses it and then scans the resulting subfolders. When it finds a music file, it 1. checks via Applescript to see if Music is running and if so, 2. copies it to Music and then trashes the file. So far, so good.

This works great for zip files that JUST contain music. Where I run into trouble is: I have another script which then scans for empty folders and trashes them. Unfortunately, music downloads from Bandcamp.com almost always come with at least one image file for the album cover, which I don't need. These image files inevitably cause the "Delete empty folders" script to skip their parent folder. Is there some way I can add an action to my original music checking script that will add the music files to Music and then delete anything else in the folder that ISN'T a music file? I can't just have Hazel go through and delete every image out of the Downloads folder because sometimes I have legit image files in there. Is there a way to put in a sort of "If-Then-Else" logic where it could say "if this is a music file do X, else if it's an image do Y, and then trash the parent folder"?

Re: Complex nested folder multi-type file moving/trashing

PostPosted: Wed Jun 23, 2021 10:33 am
by Mr_Noodle
Is there a way to identify the unzipped folder or the image file in it? Usually, the cover image has a name like "cover.jpg".

Re: Complex nested folder multi-type file moving/trashing

PostPosted: Wed Jun 23, 2021 2:55 pm
by sfritz313
Yes, the cover image almost always is "cover.jpg".

Re: Complex nested folder multi-type file moving/trashing

PostPosted: Thu Jun 24, 2021 9:39 am
by Mr_Noodle
In that case, you can have a rule match that specific file and throw it away.