4 ms·
all files are either text, binary blobs or archives (zip), no exception I personally knew about this when I needed to extract all images from a Word document i
by EDM115 2mo ago
all files are either text, binary blobs or archives (zip), no exception
I personally knew about this when I needed to extract all images from a Word document in 2015, I had the idea to rename the extension to .zip and wow a conveniently placed media folder !
since then I renamed countless file extensions to zip, just to test. it worked nearly every single time
- danielochoa0620 2mo agoHah! That's also how I first learned about the zip trick with pptx. Had never considered it generalizes outside of OOXML files. I'll give it a try next time I'm poking around another file format
- bena 1mo agoYou’d be surprised how many file formats are some flavor of “zip file containing files”. JAR/WAR, iOS apps, and others
- yellowapple 1mo agoAnd SQLite: https://sqlite.org/appfileformat.html https://sqlite.org/appfileformat.html In fact, relevantly to this article: https://sqlite.org/affcase1.html https://sqlite.org/affcase1.html
- bena 1mo agoI think it’s a decent hack. Zip is a known format, so library support is mature. It can contain a local file system. And no one is going to casually muck about in it, so you can trust the structure.
- mzajc 1mo agoSoftware like 7-Zip supports many formats, even ones that are not usually treated as archives, and recognises them by magic bytes rather than extension. You can for example add a zip extension an EXE file, and 7-Zip will open it. A much more robust way to figure out what's in a file is using libmagic, accessible through the `file` command on *nix. I don't know if there's an alternative Windows though.
- ifh-hn 1mo agoTrID: https://www.mark0.net/soft-trid-e.html https://www.mark0.net/soft-trid-e.html
- snazz 1mo agoIf you're including binary blobs as one of your options, then both text and archives are just types of binary blobs :)