Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Zip multiple files into individual archives via Automator' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Zip multiple files into individual archives via Automator
Authored by: mrsparkl33 on Aug 03, '07 09:34:00AM

for folders, try the -r option ..
zip -r "$f" $f"

from the man page -- a little confusing that the args are "foo" and "foo". the first arg is turned into "foo.zip" .. the second arg is the file spec (of files which will be placed into the .zip)
~~~
To zip up an entire directory, the command:

zip -r foo foo

creates the archive foo.zip, containing all the files and direc-
tories in the directory foo that is contained within the current
directory.
~~~




[ Reply to This | # ]
Zip multiple files into individual archives via Automator
Authored by: morespace54 on Aug 03, '07 11:30:01AM

Okay I must be doing something wrong because I did try to mix this hint (zip individual files) with the folder argument and it's not working...

I try both:

--
for f in "$@"
do
zip -r "$f" $f"
done
--

and

--
for f in "$@"
do
zip -r "$f.zip" "$f"
done
--

whitout any luck... :( I must admit I'm not used to play with Automator and Run Shell Script...



[ Reply to This | # ]
Zip multiple files into individual archives via Automator
Authored by: morespace54 on Aug 03, '07 02:14:22PM

Never mind.

I just tried the script for individual files with folders selected and it work just the same (~/foo/bar with foo selected become ~/foo.zip). Doh!



[ Reply to This | # ]
Zip multiple files into individual archives via Automator
Authored by: morespace54 on Aug 06, '07 08:17:37AM

Okay, one last thing... ;)

When I zip a folder with this script, let's say /foo from the Desktop level (~/Desktop/foo),
everything is working fine, i.e. it gives me a file named foo.zip at the same level as my original /foo folder (~/Desktop/foo).
The problem is when I unzip it. I end up with nested folders, i.e. /Users/MyUserName/Desktop/foo on the ~/Desktop folder. Is there a way to not include all those (almost empty) folders in the script?

The idea would be to make the script behave just like the "Create Archive of..." in the contextual menu



[ Reply to This | # ]