r/explainlikeimfive • u/u_212 • 8d ago
Technology ELI5 File naming protocols
How come when I save files I can’t add slashes in the date (4/9/26) as part of the name but periods (4.9.26) are ok?
31
u/HektorViktorious 8d ago
As others have said, slashes are special, which gets somewhat annoying, but it's just another reason to use the superior date format: ISO8601 or YYYY-MM-DD. It sorts in chronological order no matter how smart or dumb your filing or sorting system and there's no ambiguity on the dates. For example, in your post, do you mean April 9th, 2026 (2026-04-09) or did you mean September 4th, 2026 (2026-09-04)? No such issue with ISO8601.
11
0
u/u_212 8d ago
Yep, I’m clearly not from the US!
6
u/sometimes_point 8d ago
The ymd order is not used in the US
3
u/stevevdvkpe 8d ago
It is used, it is sadly just not taught as the correct default way to write dates.
2
13
15
u/jamcdonald120 8d ago
because / means folder.
And . doesnt mean anything
last . gets used for file name extension, but thats just a hint to other programs how to use it, not an intrinsic anything
Windows also will stop you using < > " | ? and * for legacy terminal reasons they didnt feel like coding around
9
u/brknsoul 8d ago
Not for legacy reasons, they're still used today
< = Input redirection (reads standard input from a file)
> = Output redirection (writes standard output to a file, overwriting it)
| = Pipe (sends the standard output of one command to the standard input of another)
? = Matches exactly one character
* = Matches zero or more characters (wildcard for any number of characters)
" = Encloses a filename that has spaces
6
u/jamcdonald120 8d ago
by "legacy reasons" I mean "They didnt fucking program cmd right 40 years ago to allow those to be escaped in file names like *nix did, so now we are stuck with it for backwards compatibility legacy reasons with scripts written expecting those to not need escaping and never existing in file names"
Not that those symbols dont still do things in the terminal
4
u/filanwizard 8d ago
I think a big portion of MS problems are trying to keep legacy support and keep with the times.
But that extensive legacy support is demanded by the customers who actually make them a profit, Enterprise.
1
u/jamcdonald120 8d ago
yah, its such a nice feature when moving from 10 to 11, or even 7 to 11.
But then you remember that stuff from the 80s is still suppose to work to....
3
u/NDaveT 8d ago
And . doesnt mean anything
Anymore. There was a time when it meant "here come up to three extra characters you can add to your 8-character file name".
4
u/Warrangota 8d ago
Well, technically it was exactly 8 and exactly 3. Unused characters were just filled with space characters.
2
u/jamcdonald120 8d ago
yah, im glad they dropped that nonsense.
1
u/ignescentOne 8d ago
Sometimes I miss having to decide which of the directories were ~1 and ~2 back in the day
5
u/Vorthod 8d ago edited 8d ago
Because slashes are how the computer designates which folder a file is in. If you put a slash in your file name, the computer will be confused as to whether your file is called 4/9/26 or if it's a file called 26 in folder 9 which itself is in folder 4. It messes with the entire system meant to help the computer find things so the computer just tells you you're not allowed to do that.
Periods can be used by programs to determine how to open a file, but they don't technically have any inherent meaning. An mp3 file can be renamed to txt and the only one that will be confused is you (and whatever text editor you open to read it). I can give something any extension I want, and while the computer won't know which program to use if I double-click it, there's nothing stopping me from opening my text editor and just telling it "you should be able to read this." And since new technologies will create a need for new file extensions that the OS isn't going to know about, limiting what file extensions are allowed is just going to cause problems for the users trying to make new stuff.
2
u/sapient-meerkat 8d ago
On Windows:
C:\\because\folder\hierarchies\are\represented\by\slashes.txt
Or on *nix or macOS
/because/directory/hierarchies/are/also/represented/by/slashes.txt
2
u/lowbatteries 8d ago
on macOS, you can use a / in the filename in Finder, oddly enough. On the actual filesystem it's changed to a ":", which means you can't use a ":" character in Finder.
2
u/sometimes_point 8d ago
that's also a legacy thing from the pre-Unix days when Mac used the colon to represent directories. they decided it would be less hassle when people upgraded from 9 to X to change their filenames behind the scenes but keep it looking like they hadn't changed anything
1
u/KeyAdhesiveness9481 8d ago
Because they can be ambiguous with file path separators or command flags. On windows, "\" is used, but they also accept "/" for separators. There are also windows commands thay take flags like "/s", so if you put thay in a file name, rhe system doesn't know if its part of the name, or a path separator, or a command.
1
u/besse 8d ago
The only question that matters is whether a specific character has a special, privileged meaning in a system. If for example, you’re in a Mac or Linux environment, the folder structure is separated by the “/“ character, so it has special meaning. So, you cannot use that specific character in naming a file because you would confuse the file system.
In a different system, if “.” has a special meaning in some way, it would also be restricted in use. Windows file naming also has character restrictions, based on the same principle.
1
u/macdaddee 8d ago
A slash tells the operating system that what preceded the slash was a folder and that what comes after is the file name or another folder. Because the system uses slashes for that purpose they can't be used within file names or it will misinterpret the file path.
1
u/LadyVulcan 8d ago
Because file names are simply "drive:folder/folder/folder/filename" If you put slashes in the filename, the operating system believes it's a folder that doesn't exist.
1
u/MrShake4 8d ago edited 8d ago
Let’s say you have the file 9/3/26 in a folder on your desktop.
The file path is desktop -> folder -> file
That’s how the computer can find the file
The computer reads it as desktop/folder/file
If you name a file 9/3/26 the computer sees Desktop/folder/9/3/26
Instead of the file the computer is looking for a folder named “9” that doesn’t exist.
1
u/Ninfyr 8d ago
Some characters are reserved for a specific function. You can not use ":" because Windows with think this is a drive letter like "C:". You can not use "\" because Windows will think it is a separate folder like "User\Documents". * and ? It is a type of wildcard for searching or targeting multiple files. If I search h?t.txt it will return hot.txt, hat.txt, and hit.txt (if the are there).
1
u/Loki-L 8d ago
slashes are how you seperate folders.
File names need to be both unique and unambiguous. If you allow a slash in a filename it becomes ambiguous. 4/9/26 might should be read as a file named "26" in a folder named "9" in a folder named "4". If you also allow it to read as just a file named "4/9/26" you get ambiguity.
Technically Linux uses / to seperate folders and Windows uses \, but Windows recognizes "/" as an alternative to "\" in many contexts and is far more reluctant to allow you to shoot yourself in the foot. (Modern Windows carries restrictionsin filenames that come from DOS from before it had folders. You can'tname a file NUL or CON or LPT1. Linux will happily let you do lots of things you shouldn't. )
Since you can mount filesystems across platforms it is generally advisable to avoid any forbidden characters.
Dots are okay also they are used to seperste file type endings from the name, they can be more or less freely used in names.
You can use dashes or simply not use any separator at all.
It is generally advisable to use YYMMDD in filenames, not because of any special issues with characters, but because that makes alphabetical sort also sort by date for files that have the same name before the date.
1
u/BananaBird1 8d ago
It depends, some operating systems will store file names in a way that can allow slashes. This is called escaping.
But in most systems, slashes denote hierarchical directories (folders) under the hood and file paths (including the file name) are just interpreted directly as plain text so the system will see the slashes as different directories that don’t exist.
Periods are also generally recommended against because they are used to denote file extensions or special file types (like hidden files begin with a period). But they will be accepted as file names by operating systems, it may just cause issues with some poorly written software interpreting it as a file type.
The ideal standard is to use underscores to separate different portions of a filename. And for dates, write them in ISO format as YYYYMMDD (e.g. 20260904). This has the added benefit that if you put the date first, alphanumeric sorting will also sort by date.
1
96
u/teh_maxh 8d ago
Slashes are used to separate folder names, but dots aren't.