How to create a zip when a folder contains some images ?

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

Moderator: Mr_Noodle

Hi,

I am new to Hazel.
I would like to use it to help me organize my comic books library.

The problem is that in comics format, it is still the jungle.
The best format is still cbz because it is a zip that contains all images for an album, zip is usable for free and it can be used on some platforms (like MyReadings on NAS Synology) to stream the content to the viewer (for example an ipad) without having to download the full album on it.

So here is the issue :
I have multiple folders.
Some contains CBZ (it s ok)
Some contains CBR or RAR (I had rules created to rename to rar, unarchive, archive, rename to CBZ, so it will be OK once all files will be converted).
Some contains jpgs.
I would like to know if Hazel can see if the folder contains multiples jpgs, if yes then zip the folder and in the end, rename it to .cbz

In my understanding, if I have a rule 'Dive into subfolder' once Hazel is in the folder how to handle it and retain the name of the folder ?

Thanks for your help,
Hugo
hugoheitz
 
Posts: 5
Joined: Mon May 19, 2014 3:58 am

You don't want Hazel to dive into the folder per se. Instead, you want to set up a condition which matches a folder based on its contents. You can do something like:

If (all) are met
If (any) are met for (any of its subfiles)
Kind is jpeg
Do
Archive
Rename


You can get the sub-condition by holding down option while clicking the + button to create a new condition.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thanks for your answer.

You are right BUT the folder organisation is like that :
/toplevel/
comics/
Comic1/
comic1file1.jpg
comic1file2.gif
comic1file3.png
Comic2/
comic2file1.jpg
comic2file2.gif
Publisher/
Comic3/
comic3file1.jpg
comic3file2.gif
comic3file3.png
Comic4/
comic4file1.jpg
comic4file2.gif

How can I tell Hazel to first dive and for each folder to check content ?

Can I use two rules :
1/ dive into subfolder
2/ the rule you proposed

Isn t it to late once hazel is in the folder ?

thanks for your reply !
hugoheitz
 
Posts: 5
Joined: Mon May 19, 2014 3:58 am

Unfortunately, the formatting was lost in your post but I think I know what you are saying. If the folders you want to move are at different levels, then yes, you'll also need to have Hazel go into subfolders. See the sticky post at the top of this forum on how to do that. Now, you have to modify that rule to make sure it doesn't go too deep since you want to process the Comics folders, but not the files within. I'm not sure of a good general way to only catch folders whose immediate files match certain conditions. If you can match those folders by name, then that would make things easier. You can add that condition to the rule above and then have the second subfolder rule.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Hi,

I found this while searching how to do it on the Internet.

http://superuser.com/questions/651555/r ... mmand-line

It presents a solution that is pretty clever, in fact it inspects the directory to see if there are directories under, if not, it zips it.

I thought about your proposal, if I can rename the directory I would like to convert, for example :

comics/
comic1/
comic1.cbz
comic2-TO-CBZ/
01.jpn
02.jpg
...
comic3/
comic3.cbz
comic4-TO-CBZ/
01.jpg
02.jpg
...

How can I do in Hazel to create the correct conditions to convert only the folders with the correct parameters ?

thanks for your feedback,
Hugo
hugoheitz
 
Posts: 5
Joined: Mon May 19, 2014 3:58 am

You can add a condition like "Name ends with "TO-CBZ" to match those folders and archive them. Also, if all of the comics folders are at the same level, you can alternatively use "Subfolder depth" to only zip folders at that level.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Hi,

The rules work fine.

I have just a question :
the files I convert are located on a folder on a NAS. I convert a lot of them using Hazel.

once a file has been converted (ie : all JPGs files put in a zip), all the files are deleted LOCALLY on the trash.

because the volume is too high, I have crashed because the trash on my system disk was full.

Is there a way to avoid that ?
direct delete option ?
monitoring the trash ?

maybe Hazel should stop when it becomes critical.

thanks for your help,
hugoheitz
 
Posts: 5
Joined: Mon May 19, 2014 3:58 am

You can set Hazel to delete files from the trash when it exceeds a certain limit. You can access it via the Trash pane.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thanks for your feedback.

It works fine, I monitor the trash and hazel empties it when it is too big.

I have another question about the rule :
sometimes I have some directories that are empty.
How to avoid those empty directories to be zipped ?

Thanks for your help,
hugoheitz
 
Posts: 5
Joined: Mon May 19, 2014 3:58 am

Try using the Subitem count attribute. You can also try Size though that tends to be misleading as it might include the size of the invisible .DS_Store file.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support