News:

Am able to again make updates to the Shield Gallery!
- Alex

Main Menu

Why won't they let you use : or / in file names

Started by roadman65, May 31, 2014, 09:48:37 AM

Previous topic - Next topic

roadman65

What is the reason why computers are so anal about using ":" or "/" in file names?  It makes it out to be a major taboo for Heaven's sake if you decide to put a time in your file name or a proper date because you need those two characters to do that.

What is the worst that could happen if they allow it? 
Every day is a winding road, you just got to get used to it.

Sheryl Crowe


AsphaltPlanet

: and \ are used as directory identifiers by computers, and are reserved for that purpose.

For example, C:\ is the command for the root directory of your hard drive, and the \ command identifies different file folders.
AsphaltPlanet.ca  Youtube -- Opinions expressed reflect the viewpoints of others.

1995hoo

The colon is part of the path used in the drive name (your primary hard drive is normally the C: drive, for example, since floppy drives were normally assigned A: and B:). The path begins with the drive name–for example, C:photossquirrel or whatever.

The slash is not allowed because it was already used as a command-line delimiter in several operating systems, including DOS and CP/M. For example, at the DOS command prompt dir /p brings up the listing of the files in the current directory but pauses after each screenful so you can read it. Without the /p it all scrolls by and you can't go back up to read it (well, you COULDN'T in the days of true DOS usage as opposed to the DOS box in current versions of Windows).
"You know, you never have a guaranteed spot until you have a spot guaranteed."
—Olaf Kolzig, as quoted in the Washington Times on March 28, 2003,
commenting on the Capitals clinching a playoff spot.

"That sounded stupid, didn't it?"
—Kolzig, to the same reporter a few seconds later.

sammi

#3
The slash is also a directory separator in Unix and Unix-like systems. For example, the path to a particular C code file on my computer is /home/sammi/rsm/main.c (that would be C:\Users\Sammi\rsm\main.c on Windows).

As for writing a date, there's always a hyphen. 2014-05-31.

Or if you wanted to write the date and time, none at all. 20140531101706 is a perfectly valid filename. :)

EDIT: More information on /, : and other characters here: Reserved characters and words

hotdogPi

I can use / in file names without any problem.
Clinched

Traveled, plus
US 13, 50
MA 22, 35, 40, 53, 79, 107, 109, 126, 138, 141, 159
NH 27, 78, 111A(E); CA 90; NY 366; GA 42, 140; FL A1A, 7; CT 32, 320; VT 2A, 5A; PA 3, 51, 60, WA 202; QC 162, 165, 263; 🇬🇧A100, A3211, A3213, A3215, A4222; 🇫🇷95 D316

Lowest untraveled: 36

sammi

Quote from: 1 on May 31, 2014, 10:26:07 AM
I can use / in file names without any problem.

No you can't. If you mean you can do something like C:/Users/Sammi/rsm/main.c then that's perfectly fine on Windows, but you can't name a folder 2010/2011.

Zeffy



Dammit Windows! It's too much work just to use _or_ instead of a slash!
Life would be boring if we didn't take an offramp every once in a while

A weird combination of a weather geek, roadgeek, car enthusiast and furry mixed with many anxiety related disorders

hotdogPi

Quote from: sammi on May 31, 2014, 10:31:25 AM
Quote from: 1 on May 31, 2014, 10:26:07 AM
I can use / in file names without any problem.

No you can't. If you mean you can do something like C:/Users/Sammi/rsm/main.c then that's perfectly fine on Windows, but you can't name a folder 2010/2011.

I use a Mac, and I have named a file 4/25/14, and many others are also like that.
Clinched

Traveled, plus
US 13, 50
MA 22, 35, 40, 53, 79, 107, 109, 126, 138, 141, 159
NH 27, 78, 111A(E); CA 90; NY 366; GA 42, 140; FL A1A, 7; CT 32, 320; VT 2A, 5A; PA 3, 51, 60, WA 202; QC 162, 165, 263; 🇬🇧A100, A3211, A3213, A3215, A4222; 🇫🇷95 D316

Lowest untraveled: 36

ET21

The local weatherman, trust me I can be 99.9% right!
"Show where you're going, without forgetting where you're from"

Clinched:
IL: I-88, I-180, I-190, I-290, I-294, I-355, IL-390
IN: I-80, I-94
SD: I-190
WI: I-90
MI: I-94, I-196
MN: I-90

corco

Quote from: 1 on May 31, 2014, 10:37:33 AM
Quote from: sammi on May 31, 2014, 10:31:25 AM
Quote from: 1 on May 31, 2014, 10:26:07 AM
I can use / in file names without any problem.

No you can't. If you mean you can do something like C:/Users/Sammi/rsm/main.c then that's perfectly fine on Windows, but you can't name a folder 2010/2011.

I use a Mac, and I have named a file 4/25/14, and many others are also like that.

The slash works in Mac for the displayed file name, but the true file name substitutes a colon for the slash. Try renaming another file in the same directory to the exact same name but with a colon instead of a slash- it won't work because that file name would already exist.

sammi

#10
OK, so it's a weird Mac thing. :)

This is apparently caused by the two different file systems supported on Macs: Apple's Hierarchical File System Plus (HFS+), a successor of the HFS used in Mac OS 9, and the Unix File System (UFS), used in other proprietary Unices (Mac OS X is itself a Unix). HFS+ uses colons as directory separators, which means slashes are allowed in filenames. UFS is the opposite; colons are allowed in filenames.

Because OS X supports both, it needs to transparently transform between the two filename conventions. Which is how it treats / and : as a single character in filenames.

EDIT: A StackOverflow question regarding slash vs. colon.

1995hoo

Quote from: sammi on May 31, 2014, 10:17:33 AM
....

As for writing a date, there's always a hyphen. 2014-05-31.

....

I use that format in file names all the time. I always use hyphens in dates anyway, never slashes, but when I'm organizing electronic documents for which the date matters I always use the YYYY-MM-DD format because the Windows file manager will then sort in the correct order when sorting by filename (and sorting by date doesn't always work because a document's creation date, if I scanned something, may not match its actual date). If instead you use MM-DD-YYYY (or YY), it will sort all the January documents first regardless of year, etc. (and if you don't use leading zeroes it will mess up the order even more).

If I have multiple documents from the same date I usually assign a letter suffix (e.g., "2014-05-31-a Ethanman motion to post I-366 number," "2014-05-31-b NE2 motion to say yawn," etc.).
"You know, you never have a guaranteed spot until you have a spot guaranteed."
—Olaf Kolzig, as quoted in the Washington Times on March 28, 2003,
commenting on the Capitals clinching a playoff spot.

"That sounded stupid, didn't it?"
—Kolzig, to the same reporter a few seconds later.

J N Winkler

Another thing:  although the backslash is the normal directory delimiter in Windows, the forward slash is also recognized for that purpose and NT batch commands will parse file paths accordingly.

I usually write day and time expressions in the following ways:

YYYY-MM-DD (if I want to be able to parse the date quickly by eye)

YYYYMMDD-HHMMSS (if I need second precision--usually only when I am running scripts)

None of these is culture-neutral, however; for that you are better off using the Unix epoch.  There is a Visual Basic script floating around the Internet, unixepoch.vbs, that can be called in NT batch files.  However, it will return the epoch only to the last second, truncating the milliseconds, so if you need the full count of milliseconds for a given application, it is usually enough to autogenerate the last three digits.
"It is necessary to spend a hundred lire now to save a thousand lire later."--Piero Puricelli, explaining the need for a first-class road system to Benito Mussolini

sammi

Quote from: 1995hoo on May 31, 2014, 03:26:21 PM
I use that format in file names all the time. I always use hyphens in dates anyway, never slashes, but when I'm organizing electronic documents for which the date matters I always use the YYYY-MM-DD format because the Windows file manager will then sort in the correct order when sorting by filename ...

YYYY-MM-DD is an international standard (ISO 8601). It's always how I write dates now too. And it always sorts correctly.


J N Winkler

Quote from: 1995hoo on May 31, 2014, 03:26:21 PMI use that format in file names all the time. I always use hyphens in dates anyway, never slashes, but when I'm organizing electronic documents for which the date matters I always use the YYYY-MM-DD format because the Windows file manager will then sort in the correct order when sorting by filename (and sorting by date doesn't always work because a document's creation date, if I scanned something, may not match its actual date). If instead you use MM-DD-YYYY (or YY), it will sort all the January documents first regardless of year, etc. (and if you don't use leading zeroes it will mess up the order even more).

If I have multiple documents from the same date I usually assign a letter suffix (e.g., "2014-05-31-a Ethanman motion to post I-366 number," "2014-05-31-b NE2 motion to say yawn," etc.).

I use a similar scheme when organizing extracts from archival sources, except I hyphenate everything (to avoid whitespace), use lowercase letters and digits only, don't use letter suffixes to segregate same-date material, and use "nd" when a resource can be dated to a year but not a month or day.  Example (file MT 95/132 at the UK National Archives):


1942-07-19-perrin-to-cook-on-motorways-issue
1942-07-20-cook-to-perrin-on-motorways-issue
1946-09-09-newcomen-to-hollinghurst-on-layout-standards
1947-07-08-aldington-memo-to-dres-on-cycle-track-policy
1947-10-09-hollinghurst-to-aldington-on-layout-standards
1947-11-06-anon-to-aldington-on-economies-in-design
1947-12-10-hollinghurst-to-newcomen-on-us-highways
1948-01-02-chettoe-to-aldington-on-design-issues
1948-01-02-newcomen-to-aldington-on-nottingham-agenda
1948-01-20-aldington-agenda-for-nottingham-technical-meeting
1948-01-28-aldington-on-points-for-discussion-in-nottingham
1948-01-30-cross-on-nottingham-discussion-points
1948-01-31-chettoe-notes-on-nottingham-items
1948-02-06-verbatim-transcript-of-nottingham-meeting
1948-03-20-draft-minutes-for-nottingham-meeting
1948-04-10-hollinghurst-to-aldington-on-dissemination-of-nottingham-standards
1948-04-27-hollinghurst-to-aldington-on-drakes-traffic-capacity-work
1948-04-29-sinclair-to-aldington-on-d3-roads
1948-05-11-cardell-on-suggestions-for-future-technical-meeting
1948-05-19-dre-circular-dealing-with-nottingham
1948-05-21-correspondence-dealing-with-time-distribution-of-traffic
1948-05-27-minutes-of-followup-technical-meeting
1948-06-02-aldington-on-necessity-of-cycle-tracks
1948-08-27-hollinghurst-on-nottingham-implications-for-road-widths
1948-11-26-hollinghurst-to-hugh-jones-on-nottingham-standards
1948-nd-analysis-of-nottingham-discussion
1948-nd-criteria-for-usa-interregional-highway-system
1948-nd-extract-dealing-with-motorway-design-criteria
1949-05-14-aldington-to-birtchnell-on-nottingham-standards-and-road-widths
1949-05-25-technical-meeting-of-dres
1949-06-21-aldington-memo-on-design-volumes-for-carriageway-widths
1949-08-08-newcomen-querying-alignment-standards-for-three-lane-roads
1949-09-03-bellamy-on-alignment-standards-for-three-lane-roads
1950-04-21-circular-dealing-with-visibility-distances
1950-05-26-county-surveyors-meeting-to-discuss-traffic-estimates
1950-08-18-mot-memorandum-653
1954-11-17-dres-technical-meeting-about-road-design-issues
1954-12-18-correspondence-on-lane-and-carriageway-widths
1955-03-25-hollinghurst-on-unit-lane-widths-and-three-lane-roads
1955-04-04-baker-on-three-lane-roads-and-comments
1955-04-07-stedman-and-oneill-on-three-lane-roads
1955-04-18-boyd-carpenter-on-carriageway-width-issues
1955-05-12-baker-on-grantham-bypass-width-issue
1955-05-19-jeffery-on-grantham-bypass-width-issue
1955-06-01-et-seqq-correspondence-on-carriageway-widths
1955-09-14-meeting-to-discuss-carriageway-widths
1955-nd-coburn-on-safety-of-three-lane-roads
1956-02-22-atk-grant-on-overgenerous-provision-of-dualling
1956-04-30-mot-circular-727
1956-nd-memo-on-growth-of-traffic
1958-08-12-baker-memo-to-dres-on-urban-unit-lane-widths
1959-09-10-mcneil-to-baker-on-suggested-guidance-for-traffic-estimation
"It is necessary to spend a hundred lire now to save a thousand lire later."--Piero Puricelli, explaining the need for a first-class road system to Benito Mussolini

1995hoo

I use the letter suffix in part because some courts' implementation of e-filing requires you to file certain things separately even though in paper format it all would have been stapled or binder-clipped together. Rather than uniting it all into one file using my .PDF software I simply assign the letters to keep stuff in the correct order so all documents relating to a particular party's filing stay together instead of being interrupted by someone else's stuff.

I'm sure there are plenty of different ways to do that sort of thing, but this one works well for me because I don't need something as pricey and complex as document management software like iManage or the like.
"You know, you never have a guaranteed spot until you have a spot guaranteed."
—Olaf Kolzig, as quoted in the Washington Times on March 28, 2003,
commenting on the Capitals clinching a playoff spot.

"That sounded stupid, didn't it?"
—Kolzig, to the same reporter a few seconds later.

Scott5114

#16
Before the question is asked: the reason why Windows drive lettering starts at C: is because A: is reserved for the 3½" floppy drive and B: for the 5¼" floppy drive. C: is the hard disk partition Windows is on, then lettering increases with any other hard disks or partitions, then optical drives, then removable drives, etc. Network drives can be mapped to any arbitrary unused letter (it's not uncommon to see them mapped to Z: or a drive letter pertaining to what they contain, like S: for a share drive).

Example: the first computer I ever used was configured like this in 1996: A: and B: floppy drives, C: primary hard drive, D: hard drive partition with my games and stuff on it, E: CD-ROM drive. By the time the computer was decommissioned, the hard drive had been replaced and a CD-RW drive was added: A and B for floppies still, C, D for the old CD-ROM drive that used to be E, and E for the new CD burner.

Unix has little patience for this drive-letter nonsense and displays all drives other than the one the OS is installed on as subfolders of /mnt (or sometimes /media, depending on your OS), usually named after the drive label or device name (such as /mnt/cdrom0).
uncontrollable freak sardine salad chef

sammi

Quote from: Scott5114 on May 31, 2014, 06:47:12 PM
Unix has little patience for this drive-letter nonsense and displays all drives other than the one the OS is installed on as subfolders of /mnt (or sometimes /media, depending on your OS), usually named after the drive label or device name (such as /mnt/cdrom0).

To expand on that:

An entire folder /dev on Unix file systems consists of devices, files which represent physical devices. The hard drives would be listed there as /dev/sda ... /dev/sdd, and individual partitions on each one as /dev/sda1 ... /dev/sda9. You also have files for floppy drives /dev/fd0 etc., CD-ROMs as /dev/cdrom0 etc. and so on for other kinds of devices. Those are, by default, unmounted.

/mnt (or /media) is a folder for mounting those devices, to allow you to access the data. So you can, for example, mount a partition /dev/sda5 containing my school stuff to a folder /mnt/School. Most GUI *nix systems can automatically do this for you once you connect the device. It reads the volume name, and mounts it to the corresponding folder.

The boot loader automatically loads the boot partition (on my system /dev/sda1) into the file system's root folder /. Everything else in the file system is necessarily a subdirectory of this folder.

vdeane

And those folders can be mounted anywhere.  Someone on Windows who wants to store data on a separate drive had to forgo the system generated folders (at least until 7 introduced libraries).  On Linux, you'd just delete the system-generated folders and mount the drive to /home/username.  You wouldn't even know there were multiple drives involved unless you looked.
Please note: All comments here represent my own personal opinion and do not reflect the official position of NYSDOT or its affiliates.

Thing 342

Quote from: Scott5114 on May 31, 2014, 06:47:12 PM
Before the question is asked: the reason why Windows drive lettering starts at C: is because A: is reserved for the 3½" floppy drive and B: for the 5¼" floppy drive. C: is the hard disk partition Windows is on, then lettering increases with any other hard disks or partitions, then optical drives, then removable drives, etc. Network drives can be mapped to any arbitrary unused letter (it's not uncommon to see them mapped to Z: or a drive letter pertaining to what they contain, like S: for a share drive).

Example: the first computer I ever used was configured like this in 1996: A: and B: floppy drives, C: primary hard drive, D: hard drive partition with my games and stuff on it, E: CD-ROM drive. By the time the computer was decommissioned, the hard drive had been replaced and a CD-RW drive was added: A and B for floppies still, C, D for the old CD-ROM drive that used to be E, and E for the new CD burner.

Unix has little patience for this drive-letter nonsense and displays all drives other than the one the OS is installed on as subfolders of /mnt (or sometimes /media, depending on your OS), usually named after the drive label or device name (such as /mnt/cdrom0).

Windows drive letters are totally arbitrary from a system perspective and are only used for indexing. One can install Windows on drives other than C. (However, many programs will deem this unacceptable and no longer work) I believe the default drive positions for removable disks can be changed via a registry tweak.

ZLoth

Quote from: roadman65 on May 31, 2014, 09:48:37 AM
What is the reason why computers are so anal about using ":" or "/" in file names?  It makes it out to be a major taboo for Heaven's sake if you decide to put a time in your file name or a proper date because you need those two characters to do that.

What is the worst that could happen if they allow it?
You must be using Windows. Windows has it's roots in the DOS which was a command line interface (CLI) where you typed stuff into the keyboard and things happened. Some of those "prohibited" characters have special meaning, such as:

x: - Drive letter
\ - Directory seperater
/ - Command line argument (e.g. dir /w)
< - Input is from a file into a commend (uudecode < filename.txt)
> - Output is to a new file rather than the screen (uuencode filename.txt > output.txt)
>> - Append output to the end of an existing file rather than the screen (uuencode filename.txt >> output.txt)
| - "pipe". The output of one command is to be redirected to another command (dir | more)
* and ? - Wildcards in selecting files. * meets one or more characters, ? means one character only

Trust me, I've seen some *nix script wizards put together some cool long CLI items to accomplish a goal quickly which would take quite a while using a GUI.
Welcome to Breezewood, PA... the parking lot between I-70 and I-70.

Scott5114

Pipes are especially fun, since you can do fun stuff like pipe the random number generator into your speakers for an instant white-noise machine.
uncontrollable freak sardine salad chef

sammi

#22
Quote from: Scott5114 on May 31, 2014, 11:47:07 PM
Pipes are especially fun, since you can do fun stuff like pipe the random number generator into your speakers for an instant white-noise machine.

I'm pretty sure I haven't done anything that fun, but I once counted the number of lines in my C code like this:

ls -1 *.{c,h} | grep ^[^j] | xargs cat | grep . | wc -l

ls -1 *.{c,h} - list all files with extensions .c or .h
grep ^[^j] - from that list of files, remove anything that starts with a j (I didn't want to count some JSON parser code I didn't write)
xargs cat - send that list of files to cat, to print the contents of them
grep . - find all the lines in that data with at least one character on them
wc -l - count the number of lines in the resulting data

And it just output:

2289

EDIT: As for making white noise, I can tell you this works because I just tried this myself. <_<

cat /dev/urandom | padsp tee /dev/audio > /dev/null

cat /dev/urandom - read randomness
padsp tee /dev/audio - redirect the data to an audio device (I don't know how padsp works)
> /dev/null - tee will produce some garbage, so throw it away

Scott5114

Another fun pipe target is espeak --stdin.
uncontrollable freak sardine salad chef

realjd

Quote from: Scott5114 on May 31, 2014, 06:47:12 PM
Before the question is asked: the reason why Windows drive lettering starts at C: is because A: is reserved for the 3½" floppy drive and B: for the 5¼" floppy drive. C: is the hard disk partition Windows is on, then lettering increases with any other hard disks or partitions, then optical drives, then removable drives, etc. Network drives can be mapped to any arbitrary unused letter (it's not uncommon to see them mapped to Z: or a drive letter pertaining to what they contain, like S: for a share drive).

Example: the first computer I ever used was configured like this in 1996: A: and B: floppy drives, C: primary hard drive, D: hard drive partition with my games and stuff on it, E: CD-ROM drive. By the time the computer was decommissioned, the hard drive had been replaced and a CD-RW drive was added: A and B for floppies still, C, D for the old CD-ROM drive that used to be E, and E for the new CD burner.

Unix has little patience for this drive-letter nonsense and displays all drives other than the one the OS is installed on as subfolders of /mnt (or sometimes /media, depending on your OS), usually named after the drive label or device name (such as /mnt/cdrom0).

Mostly right. A is reserved for whatever is plugged into FDD0 on your motherboard and B is reserved for whatever is plugged into FDD1. It doesn't matter what type of floppy drive it is.



Opinions expressed here on belong solely to the poster and do not represent or reflect the opinions or beliefs of AARoads, its creators and/or associates.