September 16th, 2013, 02:37 PM
Sunny Vacation Supporter!
Join Date: May 2012
Device(s): HTC One SV, Samsung Galaxy Prevail (retired), Nexus 7 (Gen 1)
Carrier: Boost Mobile
Thanked 2,097 Times in 1,108 Posts
Originally Posted by MoodyBlues
I just slapped something together, but I'm not 100% sure it's exactly what you're after.
From your snippet, it looks like you want to hard-code the working directory, then at runtime you want to manually enter the name of a subdirectory to zip, correct? Is that actually how you want it? If so...ignore the following!
This--as it stands right now--has nothing hard-coded, meaning it can be run in any directory, and it automatically finds all of its subdirectories, and zips each one as its own subdirectory-named zip file in its own subdirectory. Obviously, this can be tweaked as far as location of the zipped files, whether or not you enter a directory/subdirectory name, and so on:
for SUBDIR in `ls -d1 */`
do ZIPFILE=`basename $SUBDIR`
zip -r $SUBDIR$ZIPFILE.zip $SUBDIR
Any questions about what's doing what, just ask.
The way the directories are is my work directory has subdirectories for each section. In those subdirectories are the directories that need to be zipped in such a way that each of those directories is its own zip file. What you gave me works if I was trying to include the entire section in one zip.