I'd like a macro that, when executed, compresses each Finder selection (folder or file) to its own Zip file named after the file. Basically, it should work like Selecting a single file and then choosing File > Compress [Name].
This macro isn't doing it. It works with a single selection, but as soon as multiple items are selected, it compresses them all into a single Archive.zip, which makes sense because the File menu command changes to compress all selected files together.
Is there a way to do the For Each individual compression/ZIP?
It's a bit tricky to do because the Finder is both asynchronous, and can only compress one thing at a time. But this works (seems to work reliably for me anyway).
Can anyone suggest a way to modify the macro to do the following?
Select folder with a large number of files in finder (say 400 for example)
Compress the files to zip files in groups of 10 (without splitting any individual files into multiple zip files)
Use a counter variable in the For Each Action, and add the path of each file to a Variable. When the counter reaches 10, pass the Variable with paths to an Execute Shell Script that uses the zip (or other compress) command to create the zip file. Reset the counter and keep looping.
I'm helping a family member who has a photography website which can import and processes zip files, however, it crashes when the zip file, or image files are too large. I'm basically trying to automate the process of zipping the 400 image files into groups of ten without splitting any of the files between two zip files.
I am delighted with this macro. I wonder should I submit it to the macro page on its own thread? It probably has very very limited use for other people, but it will save me loads of time.
I eliminated the whitespace issue by renaming the directory and files until there are no spaces. I could probably do better there.
I also changed the ENV_PATH variable in preferences to /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin (though I don't fully understand the paths I admit, but it seems to work.
Does anyone have any suggestions how I should handle remaining files at the end. Say I highlight 10 files and process them in groups of 3, I have one left over, that I'd also like to be zipped, even if by itself.
The dangers of helping! I was proud of my macro, but yours is a work of beauty! I still need to examine it in detail to see how you assign multiple values in one KM Variable, and also new to me is the realisation that you can count the files in a folder (though its unsurprising).
I will leave the submitting to you, as I think your macro is superior here. I'm glad my work helped make it happen. Thanks for your assistance.
I needed to use the macro on the weekend, and it didn't work for me, so I resorted to my old macro, and vowed to go look before I started asking questions. I finally did that today. Turns out somehow I managed to delete a single '%' after a variable, breaking the macro! So I'm glad I had a look.
My query as to assigning multiple values to a single variable was answered also, it simply adds more text to the end of the string. So simple, yet effective. I'm going to shorten the zipfile names myself, the zip files are already numbered and the long file names stress me out!
Thanks again, and please post this macro to the macro library, it's really excellent.