Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 208
nabla Avatar asked Feb 11 '16 08:02

nabla


People also ask

Can you have a decimal in a file name?

Decimals are allowed, however colons (":") are not.

Can File names contain dots?

Illegal Filename CharactersDon't start or end your filename with a space, period, hyphen, or underline. Keep your filenames to a reasonable length and be sure they are under 31 characters. Most operating systems are case sensitive; always use lowercase. Avoid using spaces and underscores; use a hyphen instead.

What is decimal name?

The decimal numeral system (also called the base-ten positional numeral system and denary /ˈdiːnəri/ or decanary) is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers of the Hindu–Arabic numeral system.


2 Answers

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.

like image 174
Mushroom Man Avatar answered Oct 03 '22 09:10

Mushroom Man


Either put the filename in quotes:

$file="abc.def"

Or use an escape character ( which varies with OS )

copy data.txt to qwe\.rty
like image 33
Arif Burhan Avatar answered Oct 03 '22 08:10

Arif Burhan