Hello,
I am looking for a way to go through a folder containing image files and ZIP them based on a substring. I started doing this using Applescript and Automator, but this was a very slow process. I came across the following Bash command
Code:
for i in *.JPG; do zip "${i%.*}.zip" "${i%.*}".*; done
which zips each file individually. And I came across this command
Code:
for q in *_*.JPG; do mkdir -p "${q%_*}"; mv "$q" "${q%_*}"; done
The latter makes folders based on the common denominator.
As a programming newbie, what can I change in the ZIP command to achieve grouping the files and zipping them. The file names consist of an object number, following by underscore and a running number which may be up to three digits depending on the files concerning a specific object number (e.g., XYZ04999_01.jpg, XYZ04999_02.jpg, XYZ04999_03.jpg, etc.).
I'd be grateful for some help.
Thank you!