nabla
nabla

Reputation: 235

Decimal mark in a filename

Is there a canonical way to write decimal marks in a filename? Dots, commas and apostrophe symbols are problematic.

Forgive me if this has been asked before, but I couldn't find anything similar. Maybe I didn't know how to look for it.

Upvotes: 9

Views: 7801

Answers (2)

Arif Burhan
Arif Burhan

Reputation: 505

Either put the filename in quotes:

$file="abc.def"

Or use an escape character ( which varies with OS )

copy data.txt to qwe\.rty

Upvotes: 1

Mushroom Man
Mushroom Man

Reputation: 400

Windows (7; probably relevant to later versions)
Through experimentation I have discovered that you can name files with "." in them as long as the file extension is after the last ".". For example: ".qerg..docx" is an acceptable file name, while "..rwhg..docx." is not. Here I have a picture of a .txt file I named "...":

screenshot

Macintosh OS 9
Decimals are allowed, however colons (":") are not.
Macintosh OS X
Same rule as Mac OS 9, however file or folder names are not allowed to begin with a decimal.
Unix
The characters not allowed in Unix file and folder names are slash ("/") and NUL ("\0"), however in most Unix shells these characters (\ ? * | " < >) need to be escaped with a backslash, for example:
The file name:

What is > life?

Would need to be entered into the shell as:

What\ is\ \>\ life\?

Further reading:
There is a helpful Wikipedia article about your question here.

Upvotes: 4

Related Questions