Files, folders and file extensions
A file is a run of bytes with a name, and a folder is nothing more than a list of names. A file extension, the letters after the last dot, has no bearing on what is actually inside the file: it only tells the operating system which program to open it with.
- Lesson 5 of 12
- Beginner
- Free, no signup
One root and four branches, no more
The number at the front of each folder name exists only so their order stays the one you chose, not the alphabetical one.
-
01-clients
One folder per client, under the same name you use on the invoice
-
02-active
Only what is in your hands this month; if it grows, something finished and was never moved
-
03-archive
A finished project moves here; it does not get deleted
-
04-personal
Everything unrelated to work, so it never mixes into the work backup
This is an example, not a standard. If your work has another shape, change the branches, but keep their number small and do not go below three levels.
Last checked: Facts and tool names in this lesson are re-checked against their sources on this date.
What a file is and what a folder is
A file is a run of consecutive bytes that the operating system has given a name to. That is all. Whether it is a photo, a text or a program, on the disk they are all the same thing: numbers one after another.
A folder is nothing but a special kind of file: one that, instead of a picture or text, holds a list of the names of other files. Which means that when you move a file from one folder to another on the same disk, usually not a single byte of the file itself moves; only its name is transferred from one list to another. That is why moving within a disk is instant while copying to a different disk takes time.
A path is the full address of a file, the chain of folders from the root down to the file itself. Windows writes it with backslashes and macOS and Linux with forward slashes, and that one small difference is the origin of many of the errors you see when files move between two systems.
One important consequence falls out of that plain definition: a file name is data in its own right. The name of a file can give away a client name, a contract amount or the subject of a case without anyone opening it. The AI part of this lesson comes back to exactly this point.

What a file extension is, and what it is not
The extension is those few letters after the last dot in a file name: .pdf, .jpg, .docx. It does exactly one job and no more: the operating system looks in its own list to see which program is registered for that extension and hands the file to it.
Now the part almost everyone gets wrong: the extension does not change what is inside the file, and it does not describe it either. An extension is a label stuck on a box, and anybody can swap the label. The contents of the box stay where they are.
We tried this on this very server. We made an eight by eight PNG image and copied it, with no conversion at all, to a name ending in .jpg. The file command still said PNG, and the image reading function in PHP still returned the type as image/png. The reason is in the file itself: its first eight bytes were 89 50 4E 47 0D 0A 1A 0A, which the official PNG specification calls the PNG signature and says every PNG datastream begins with.
So there are two separate things: what a file claims, which is the extension, and what a file is, which is written in its first bytes. Serious programs look at the second. The practical consequence for you: when an image refuses to open with a message about an unsupported format, renaming it almost never fixes it, and if it does, the extension had been wrong from the start.
Four steps between the double click and the file opening
Up to the third step nobody has looked inside the file. That is where the whole extension story comes from.
-
1
The extension is read
Only the letters after the last dot, not one letter more
-
2
The program is looked up
The operating system checks its own list for which program is registered to that extension
-
3
The file is handed over
Without a single byte of its content having been read
-
4
The content is read
Only here does it become clear what the file really was, and sometimes that is far too late
On macOS and Linux this chain differs slightly and the content is sometimes consulted too, but there as well the third step comes before the fourth.
Why a file called photo.jpg.exe is dangerous
Now put the two things we have said together: the extension is only a label, and the operating system looks at nothing but that label when it picks a program. The result is the oldest and still most effective trick you meet in email and messaging apps.
A file called photo.jpg.exe is, to the operating system, an executable program, because its real extension is exe; the jpg in the middle is just part of the name and means nothing. And if extension display is switched off in your file manager, that same file appears on your screen as photo.jpg. You see a photo, and you double click a program.
So the first thing worth doing today is this: turn on file extension display. Microsoft has written the path itself, and its sentence opens with exactly this, that if you do not see file name extensions in File Explorer, on Windows 11 choose View, then Show, then File name extensions, and on Windows 10 tick the same box under the View tab in the Show/hide group. You do it once and it stays.
And one point that comes from our own code: cleaning up a file name does not stop this trick. We tested the standard WordPress function for tidying file names on this machine and it handed photo.jpg.exe back untouched; all it did to other names was turn spaces into hyphens. What actually stops it is two other things: a list of allowed extensions, and reading the file own bytes. The upload layer of our freelance platform does both, and the comment inside that same file says outright that checking the extension alone does not see this.
The subject continues, and this lesson is not its place; the security track covers both the kinds of malware and where software should be obtained from.
Naming that still works six months later
The problem with naming is not that you are untidy. The problem is that you write the name for yourself at that moment, not for yourself six months later. That person does not know what "final" meant or which "copy" is the newer one.
Three rules are enough and the rest is decoration.
Always write the date as year then month then day, like 2026-09-06. The reason is not beauty; the reason is that in this shape, sorting alphabetically is exactly the same as sorting by time. 6-9-26 does not have that property and, on top of that, does not say which number is the month.
Show the version with a number, not an adjective: v01, v02, v03. The leading zero matters, otherwise version 10 sorts before version 2. The word "final" is an adjective, and an adjective leaves room for the next adjective; that is exactly how we arrive at "final2".
Put the name of the thing the file belongs to at the front, meaning the client or the project. That way every file for one client sorts together even when they are all dumped in one folder.
One necessary honesty: no scheme survives four people on a shared drive unless it is written down and one person owns it. If the files are a mess again after three months, the scheme was not the problem; it had no owner.
A file name that lasts and one that does not
The test is one thing: can someone reading this name six months from now decide without opening the file.
Still readable six months later
- The date as 2026-09-06, because alphabetical order becomes time order
- The client or project name at the front of the file name
- Version as a number with a leading zero: v01, v02, v10
- A hyphen instead of a space; a short but readable name
Meaningless by the following week
- final, final2, final-real
- A date as 6-9-26, where nobody knows which number is the month
- important document, new, copy of important document
- Five nested folder levels hiding a single file
These rules only work while one person owns them. On a shared drive, an unwritten rule always loses.
Should I make folders or rely on search
Our position: deep folder trees almost always fail, and the reason is clear. Every extra level is an extra decision at the moment of saving, and a tired person does not make that decision; the file stays on the desktop.
What survives is a simpler combination: two, at most three, levels of folders, plus good names. Then search works, because search answers on file names and your names mean something. Search is not a substitute for order; the person who benefits from search is the one whose naming was right.
There is one practical rule that gets said less often: make a folder whose job is being finished with. A completed project should move from the current folder into the archive, not be deleted and not left in place. A current folder that only grows is the desktop under another name.
And the last thing, which has nothing to do with tidiness and matters more than all of it: none of this is a backup. A tidy folder that exists on one disk only is just as gone when that disk fails as a messy one. That subject has a lesson of its own, and it is the logical next step from here.
The fast path, with AI
The usual advice is "be organised from the start", which is no use at all for a folder with four hundred jumbled files. The fast route is to pull out the real list of file names and ask a model for a rename plan, not for the renaming itself. What turns this from a trick into a method is the fourth column of the table: any name the model is not sure about is marked "leave alone" in that column and stays untouched.
- Get the list of names, not the files. Inside that folder, dir /b on Windows and ls -1 on macOS and Linux is enough.
- Before pasting, read the list once yourself and take out any name that should not leave the building. A file name is data in itself, and this is the one step nobody does for you.
- Give it the recipe below. The job is pattern matching over text, not judgement, so a fast cheap model is enough; see the AI section of this site for the current pick.
- Rename the first five rows by hand and look at the result. Until you have seen five rows with your own eyes, do not run any script over the whole folder.
Copy-ready recipe
This is a list of file names from one folder. You do not have the contents of the files and you must not guess them.
My naming rule: {e.g. date-client-subject-version}
The list of names:
{paste the list here}
Give me a table with four columns:
current name | proposed name | which part of the current name you took it from | leave alone
Hard rules:
- Never write a date that is not already in the name itself.
- Do not convert a Jalali date into a Gregorian one; leave it exactly as it is.
- If you are not sure from the name alone, put "leave alone" in the fourth column and leave the second one empty.
- Do not complete any name and do not add any word.
Before you trust the output: The last two hard rules in that recipe are not decoration; they came out of an actual run. When we did this on a five name sample list, two of the names carried no date at all and the "date-client-subject" rule pushed towards inventing one, and one name carried a Jalali year that cannot become a Gregorian date without knowing the month. The "leave alone" column was added after that run. And one limit no prompt removes: the model has seen only the names, never the contents. A file called report may well be last year report.
AI in this kind of work
On this subject AI does one thing genuinely well: it pulls a pattern out of a heap of jumbled names and proposes a naming rule, work that is tedious for a person and effortless for a model. What it cannot do is precisely the subject of this lesson: it does not know what is inside a file, because all it has seen is the name you pasted.
Tools that actually help
- Gemini Suited to turning a long list of names into a rename table, since it handles long text comfortably. Iran is not on Google own supported countries list; the detail is on this tool page on this site.
- Claude Responds better to the hard rules in that recipe and is readier to fill the "leave alone" column instead of inventing something. Iran is on neither of the company two supported countries lists.
- ChatGPT Good for proposing a folder structure from a description of your work, which is the one task here that needs no sensitive input at all. Same access limitation.
Where it backfires
The risk here comes from an unexpected place, and it is the thing we said in the first part: a file name is data in itself. The list of names in a work folder usually carries client names, project titles, sometimes an amount and even a phone number out with it, and all of that lands in a chat without a single file being opened. Google own privacy page for Gemini says plainly not to enter information you would not want a human reviewer to see or Google to use to improve its services. So read the list yourself before you paste it. The second risk is subtler: the model has not seen the contents of the files, so any sentence it produces about what a file is has been guessed from the name. That is exactly the mistake this whole lesson is about, only this time the model is the one making it.
Sources: Google: Gemini Apps Privacy Hub (last updated 10 August 2026) Anthropic: is my data used for model training
Where this advice stops
The extension is a convention of the desktop world. On a phone and inside the web you usually never see it, and a file arriving through a messaging app may have had its name changed entirely. More importantly, reading a file real bytes proves what a file is, not that it is safe: a perfectly valid docx can carry a harmful macro and a genuine PDF can have a script inside it. And naming rules live only as long as one person owns them; on a shared drive with four people, even the best scheme drifts within a season unless it is written down and has an owner.
From our own work
We ran the "the extension does not decide the content" claim on this server the same day, and it has five lines of output. We made an eight by eight PNG image, copied it with no conversion to holiday.jpg, and then: the file command, version 5.45, said PNG image data, 8 x 8 for both files; the getimagesize function in PHP returned image/png for that same jpg named file; and the first eight bytes were read with xxd and were exactly 8950 4e47 0d0a 1a0a, the signature the official PNG specification says every PNG begins with. We tested the second half too, because everyone assumes cleaning the name is enough: on this machine the WordPress sanitize_file_name function turned the name of a Persian invoice file into a hyphenated version but handed photo.jpg.exe back exactly as it was, untouched. What actually stops this on our own platforms is written in rgb-freelance/includes/uploads.php: first the list of allowed extensions, then wp_check_filetype_and_ext against the temporary file, and getimagesize for images. The comment above that function, which we wrote while building it, says that checking the extension alone does not see this. More interesting still, that same layer sometimes changes the extension itself: if a PNG comes out smaller as a JPEG, the file is stored with a jpg extension and the new path is returned. So in our code too, the extension follows the content, not the other way round.
Real follow-up questions
How do I show file extensions in Windows?
On Windows 11, in File Explorer go to View, then Show, and choose File name extensions. On Windows 10, tick the same box under the View tab, in the Show/hide group. You do it once and it stays, and after that a file with a double extension gives itself away at first glance.
What happens if I change a file extension?
The contents do not change at all; the operating system simply hands it to a different program from then on. The usual result is that the program refuses to open it or reports a format error. Changing the extension does not convert a file; converting means a program has to read the content and write it out again.
Is there a problem with naming files in Persian?
On your own computer there is usually no problem at all, and on this site a Persian name survives with only the spaces turned into hyphens. Trouble starts when the file travels: an archive made on one system and opened on another sometimes shows broken names, and a Persian name in a web address becomes a long encoded string. For files that are going onto the web, a Latin name is the safer choice.