Linux – “Mac-style” unzipping on linux

linux-mintosxzip

I'm using Linux Mint MATE edition, in case that's relevant.

I don't know if this is Dropbox specific, but when i download a zip of a folder that was originally produced on a Mac (and that has lots of nested subfolders) from dropbox, and unzip it on my Linux machine, it's completely messed up: all folders have a duplicate with a downcased version of their name, and the subfiles appear in the duplicate instead of the original. If one of my Mac-owning colleagues unzips that same zip, then it's fine.

This is what i should get:

enter image description here

And this is what i actually get:

enter image description here

My guess is that this is somehow related to the fact that Macs are non-case-sensitive with file names, and thus there's some weird incompatibility between file system metadata, or something.

Does anyone know of a linuz unzip tool which replicates the behaviour of the Mac unzipper, or otherwise produces the correct result? I don't mind if it leaves the_MACOSX folder in there (i can just delete these), as long as the main folder is fine.

Best Answer

It does look like the problem is that the zip file uses inconsistent case variations for directory names. This is exactly what the ciopfs filesystem is for: it provides a case-insensitive view of a directory tree. There's an Ubuntu package. Create a view of an existing directory by mounting the ciopfs filesystem on a temporary directory, unpack the zip inside that view, and you'll get the archive extracted in the original directory.

mkdir ~/case-insensitive
ciopfs ~/temp ~/case-insensitive
cd ~/case-insensitive
unzip -x __MACOSX -x '__MACOSX/*' /path/to/zip
cd ~/temp
fusermount -u ~/case-insensitive

If that doesn't work for some reason, my next candidate would be the Python zipfile library (example).

Related Question