May 20, 200917 yr i have about 6000 zip files i need to unzip but must ignore any paths stored in the archive and unzip into the current directory ignore any errors in the zip file and skip it i could do this in winrar but file roller which comes with ubuntu is no good and the unzip command does not seem powerful enough - please correct me if i am wrong anyone have any suggestions many thanks PastEgo
May 20, 200917 yr You're looking for the 'unzip' command. The "-j" option will move all the files into the root directory. I'd suggest doing a unzip -j *.zip ~/Desktop/zip Note that I can't see a way to avoid it choking on errors, but it will tell you the problems and you can remove the offending files.
May 20, 200917 yr Author great the problem is that a large number of files have nested sub directories within which i dont want i just want the file itself that is stored in there will the -j do that thanks again PastEgo
May 20, 200917 yr great the problem is that a large number of files have nested sub directories within which i dont want i just want the file itself that is stored in therewill the -j do that thanks again PastEgo from the unzip manual page [-x xfile(s)] An optional list of archive members to be excluded from processing. Since wildcard charac‐ ters normally match ('/') directory separators (for exceptions see the option -W, this option may be used to exclude any files that are in subdirectories. For example, ''unzip foo *.[ch] -x */*'' would extract all C source files in the main directory, but none in any subdirecto‐ ries. Without the -x option, all C source files in all directories within the zipfile would be extracted. so I would expect that unzip filename.zip -x */* would do the trick. If your zip files are in multiple directories as well you could say find . -type f -name \*.zip -print -exec unzip {} -x "*/*" \; to find all .zip files starting from current directory and unzip all of them to the current directory. Only files in the root directory inside of the zip files will be extracted. HTH
Create an account or sign in to comment