View Single Post
Old September 17th, 2013, 04:02 PM   #935 (permalink)
MoodyBlues
- Crazy peacock person -
Thread Author (OP)
 
MoodyBlues's Avatar
 
Join Date: Jan 2011
Location: /home/LosAngeles
Posts: 3,231
 
Device(s): Kindle Fire HD 8.9" (rooted), Motorola Atrix 2, Motorola Atrix 4G (retired), Motorola Bravo (retired
Carrier: AT&T

Thanks: 1,067
Thanked 1,531 Times in 937 Posts
Default

Quote:
Originally Posted by palmtree5 View Post
Not really unless I push it to the upcoming weekend as I have more important things to do between now and Friday
Okay, here's my script:

[high]
#!/bin/bash
SUBDIR=$1
SAVEIFS=$IFS

IFS=$(echo -en "\n\b")
cd $SUBDIR

for SUBDIR2 in `ls -d1 */`
do ZIPFILE=$(basename "$SUBDIR2")
zip -r $ZIPFILE/$ZIPFILE.zip $SUBDIR2
done

# cleanup
IFS=$SAVEIFS
[/high]

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.
__________________


MoodyBlues is offline  
Reply With Quote
The Following User Says Thank You to MoodyBlues For This Useful Post:
EarlyMon (September 17th, 2013)