File name vs. file content
There seems to be a major misunderstanding what a file name tells about the file itself. Most people without some real knowledge about computers (mostly Windows users) tend to think that the content of a file and its name are connected to each other.
This is just wrong
The name of a file doesn’t tell anything about the file itself. For example we will take a simple text document. Let’s say it’s the readme.txt of some downloaded program.
When we now change the name of the file from “readme.txt” to “song.mp3″ what file do we have know? A text document or an audio file?
The category of people with no knowledge (doesn’t matter if they think they have some) will now say “Well that’s easy. It’s an audio file”. Wrong! We still have a simple text document.
To explain this we will have to take a deeper look on how the operation system (or to be correct: the filesystem) stores its files. I will only talk about NTFS since mostly Windows users live in this dreamworld as I stated above. However all major filesystems like for example ext2,3,4 should act more or less the same way.
When you format a hard disk with NFTS the Master File Table (MFT) will be written to the middle of the disk. The MFT can be compared to a database. It holds information about how big the disk is, what files are saved on the disk, and most important where the file is located on the physical disk.
Each entry in the MFT will contain the name of the file, the position on the disk, some file attributes (like read-only), permissions, and some more things which aren’t important in this matter. However have you noticed something? The content of the file is not saved in the MFT entry for the file but seperately somewhere else on the disk.
When we now rename our file “readme.txt” to “song.mp3″ Windows will modifiy the entry in the MFT for the file. It will change the filename to “song.mp3″. The content of the file however will not be touched at all.
We still have the same content inside the file. No matter what name we give it, it will always be a simple text document.
So what is the filename – or more precisely – the file extension (the part after the dot) for ?
The name itself purely exists for humans like us. The computer doesn’t need a name for a file. It has some sort of IDs (1,2,3,4, … for example) to seperate the files from each other. It can give us some hints about what is in the file but only if the author of the file was kind enough to give a meaningful name to the file.
The extension of the file (e.g. txt, mp3, zip, …) is only used by the operating system to chose which program should be used to open a file type. Maybe you know the dialog which will pop up if you try to open a file without an extension or with an extension that your operation system doesn’t know about. You will be asked to select a program to open the file with.
So if you change the extension of a file to something different you will only change how the operating system tries to open the file. For example if you now start a text editor and open the “song.mp3″ file you will still see the text that was written in the original text document.
So from now on you won’t have argue with people that believe you will get an audio file if you rename something to “foo.mp3″. Instead you can just point them to this article and be happy
Written by Sylence. Published on January 1st, 1970