September 17th, 2013, 08:21 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 1,899 Times in 999 Posts
Originally Posted by MoodyBlues
Okay, here's my script:
IFS=$(echo -en "\n\b")
for SUBDIR2 in `ls -d1 */`
do ZIPFILE=$(basename "$SUBDIR2")
zip -r $ZIPFILE/$ZIPFILE.zip $SUBDIR2
As always, this can be tweaked as needed/desired. Right now, it's taking you to the directory whose name you enter at runtime, then it's doing its thing as far as locating subdirectories and zipping their contents. It's creating the zipped files in each subdirectory; of course that can be changed to wherever you'd prefer.
And thanks to EM for the $IFS idea.
Originally Posted by EarlyMon
Don't have to pump those through sed to escape any blanks in the path name?
Apparently not. What Moody posted works