Hi, I'm looking for a command to unzip to seperate dirs.
I use this for multiple unzip
for X in `ls`; do unzip $X; done
but that unzips in current dir, are there any commands to recursively create a new folder and each consequetive unzip goes in the respective folder? Thanks.
pmessri
08-12-2007, 05:13 AM
$ c=0; for X in `ls *.zip`; do mkdir $c; unzip -d $c -qq $X; c=$(($c+1)); done;
This will create directories 0..n (number of zip files you have) and unextract each zip file individually into each directory that is created.
Let me know how it goes :)
Perfect, but one wierd thing, after those folders are made and I delete them they continue from the # left off if I execute the command again. Thanks a lot for your help though :D
pmessri
08-12-2007, 08:10 PM
xfob,
Yeah, if you are still using the same bash shell session it will do that, it's because $c is still set. You can unset c and re-run the command, or end your shell session and start another one.
Hope this helps.
Oh I just realized, folder 1 unzips the second .zip file in the directory, the first zip file doesn't get unzipped
pmessri
08-13-2007, 10:48 PM
c begins at 0, that means 1 is really 2 :)
if the zip file didn't un-extract it must mean the zip file
has some issues. Try manually unzipping that file.