eozzy
eozzy

Reputation: 68670

Dot in file name?

Is it okay to use a "." (dot) in file names instead of camelcase or dashes etc.. for example:

ico_active.user.png

Will it cause any performance or browser compatibility issues or some other disadvantage?

Thanks!

Upvotes: 17

Views: 32683

Answers (5)

MrWatson
MrWatson

Reputation: 516

Dots in filenames...

  • can be somewhat problematic
  • certainly make more work when processing filenames
  • are best avoided if you can!

Consider:

  1. A dot is used as the separator between base-filename and extension.
  2. "." & ".." are reserved to represent the current & parent directory.
  3. On *nix systems a dot at the start of a filename makes it a hidden file.
    • Thus on a Mac in Finder you are not allowed to give a file a name starting with a dot: Mac Error
  4. On Windows you are not allowed to have a dot at the end of a filename
    • so dots at the end are simply removed
  5. Multiple dots
    • could represent multiple (embedded) extensions, for example: something.tar.gz
    • or other information, like version numbers, for example: something_version.1.2.6.ext
  6. When copying files between different systems
    • what works on one system may not on the other.
    • It is not possible to copy a file with a dot at the end of its name from mac to pc
    • It is not possible to copy a file with a dot at the beginning of its name from pc to mac

Unsurprisingly, certain programs have problems when files have dots in their names, for example:

  • Mail apps cannot correctly, automatically link a file-with-a-dot-at-the-end in a text mail, because the trailing dot will be interpreted as the dot at the end of the sentence Email link fail
  • FileMaker databases cannot correctly introspect, if they have dots in their names
  • and many more!

Clearly the semantics of dots in filenames is quite complicated, confused & confusing.

Just.stay.away!

Upvotes: 4

Dour High Arch
Dour High Arch

Reputation: 21712

Different OSes have different rules for filenames. For example, filenames cannot consist only of dots. In Windows filenames cannot end with a dot.

There is a convention where file types or formats trail dots; for example a something.tar.gz file is interpreted as the file or folder "something" that has been tar-ed then gzipped.

Dots are also problematic when matching filenames using regular expressions because . is a metacharacter while underscores and letters are not.

Upvotes: 5

Jon Hanna
Jon Hanna

Reputation: 113272

If you save the response, then the last part will be used as the file name by some older browsers, but apart from that it's ignored. It used to be fun little joke to play on people to make a URI like ".jpeg" do something interactive because it was really a text/html with some javascript or flash, but these days people are too likely to know how it's done to serve as a prank any more.

IIS does have issues if the period is the final character of the URI, for reasons that escape me.

Upvotes: 7

Jonathan Leffler
Jonathan Leffler

Reputation: 753970

Dot is about as safe a punctuation character as there is, except that many systems at least partially determine (assume?) the type of contents from what follows the last dot in the name.

Upvotes: 0

Jacob Nelson
Jacob Nelson

Reputation: 3006

Yes it is. It will look at the trailing .* for the "File Extension".

Upvotes: 3

Related Questions