Or a renamed txt. Eg, .js, .py, .css, .html, .json
Thank God they went with file name extensions so we didn’t have to preface every source .txt file with header content to instruct the editor about what kind of content it would have.
<!DOCTYPE JAVASCRIPT>
Why do I need to put that at the start of bash, desktop, and html files then?
Because both ways are used. Microsoft relies on file names, linux on the first bytes of the file.
Not quite correct. For html, that is to signal standard compliance, you can leave it away and the browser will still handle it. For the bash one, all (most) shell scripts use .sh, so you need to give a shebang to tell the loader which executable (sh, bash, zsh, csh, …) to use
Also on Linux xdg does take file extensions into account, just executables do not
I don’t get it… I must be missing something about zipped files.
OP refers to the fact that you can rename some filetypes to .zip and unpack them.
Notable examples microsoft office files (.docx) or android apps (.apk).
Counterexample are media files (mp3, mp4, jpg).
OP refers to the fact that you can rename some filetypes to .zip and unpack them.
So… you mean the zip program just rename them back? Why?
I think it makes sense from a programming view. When you have a document, you can add all the media files and pack them together as one archive. Then the program sets the filename to .docx so everyone knows that they need an office program to open that file.
For the users, all you need to know is what program can open which files. If every document would be named .zip, you would have no idea if it was a spreadsheet or slides for your presentation.
I got that from the other answers. I was just very confused why I’d have to rename them to “.zip”.
I still don’t get why it is “most” files.
You don’t have to rename them, doing so would just make windows default to using the builtin zip extractor.
If you have 7-zip you can just right click the file you wan to explore and try to extract it.
Take a .docx file, using 7-zip, exctract it.
You will get an entire folder structure with several files inside the .docx file.
What OP means is that several programs use a zip file as a container for all the stuff they need in a save file.
The file extention is just a name for the OS to find the proper program to open the file.
Not really. The “file types” you’re talking about are expected to contain whatever things in a very specific format.
You’re really just saying “many file types use an efficient and common compression algorithm”. Which is correct, obvious, and to be expected.
A .docx is just a zip file with xml documents in it.
What happens if I put an mp3 or an epub file in there with the xml? Is it still a word document?
Maybe, I was just giving an example. Like Java jar files are just zip files with other jars in them.
My point is that the formats we’re talking about define the content. Like it’s not “just a zip file” merely because it’s compressed. The format defines the data that may be included.
AKA “Why zip doesn’t compress things much any more”.
I see images, audio, or video files distributed in zips far too often. You’re getting maybe a percent of compression if you’re lucky; just distribute the raw files or use a non-compressed bundle format like tar.
But then,
tar -xzvf filename
With a bad pretend accent:
Xtract
Zee
Vucking
File
tar -cf stop-nuke.tar
My 1.5gb log folders disagrees. But I never tried opening a .txt in 7-zip.