This will extract all the zip files into the current directory, excluding any zipfiles contained within them.
find . -type f -name '*.zip' -exec unzip -- '{}' -x '*.zip' \;
Although this extracts the contents to the current directory, not all files will end up strictly in this directory since the contents may include subdirectories.
If you actually wanted all the files strictly in the current directory, you can run
find . -type f -mindepth 2 -exec mv -- '{}' . \;
Note: this will clobber files if there are two with the same name in different directories.
If you want to recursively extract all the zip files and the zips contained within, the following extracts all the zip files in the current directory and all the zips contained within them to the current directory.
while [ "`find . -type f -name '*.zip' | wc -l`" -gt 0 ]
do
find . -type f -name "*.zip" -exec unzip -- '{}' \; -exec rm -- '{}' \;
done
I've done some digging in the source code (unzip60 from Ubuntu raring, though I suspect older versions don't differ much).
The error in question is internally called TruncNTSD
and defined in extract.c:295
. Most uses of this message, as expected, are in win32/win32.c
and indeed refer to NTFS security data, however there's only one place in the code where you should ever get this error outside of a win32 system (since you reported seeing it on ubuntu).
The place in question (extract.c:2118
) is in a function called TestExtraField
. As Wikipedia explains:
.ZIP file format includes the extra field facility within file headers,
which can be used to store extra data not defined by existing .ZIP
specifications, and allow compliant archivers not recognizing the fields
to safely skip the fields.
That's indeed what NT does to store security information. Importantly, the function printing the error comments
/* we know the regular compressed file data tested out OK, or else we
* wouldn't be here ==> print filename if any extra-field errors found
*/
So if you can unzip the files themselves fine, it looks like this error is safe to ignore.
Looking further, the only place outside of win32 code that raises this error (assuming it's not a horrible bug in unzip) is test_compr_eb:extract.c:2227
, which from a glance at the code looks like it occurs when a zipped file has associated extra fields that are marked as compressed, but the field data has a length of 0 bytes.
How this comes about I don't know - perhaps the program creating the zip files does this by accident, perhaps the extra fields are filtered out somewhere by security software. In any case, it looks harmless and probably has nothing to do with NT security at all. In conclusion, if your files unzip fine, it's completely safe to ignore.
Best Answer
By default,
gzip
will only decompress files with extensions from a limited list—rather than examining the filemagic
to determine if it is a gzip'd file. From a comment ingzip.c
:get_suffix()
:To use input files which are in fact gzip'd but are not named following
gzip
's expected conventions, provide the suffix explicitly as per thegzip
manual page:or use redirection to prevent
gzip
from seeing the filename: