6

I would like to name my files and folders according to a specific date, e.g. 03.04.2016.

I see I can use them but are there any disadvantages to using periods in files or folder names?

orschiro
  • 1,005
  • 6
    You might want to consider using the ISO 8601 date format (e.g. 2015-12-31), which would make it easier to sort your directories chronologically using only their name. – n.st Apr 03 '16 at 14:44
  • Since the period or dot has special meaning in the context of a regex, you would need to escape them whenever using grep, find, or other utility. You might want to stick with the '-' hyphen unless you have some reason for wanting to use a '.' – bsd Apr 03 '16 at 14:51
  • Retitled for reopen – Michael Durrant Apr 04 '16 at 18:54
  • 2
    @MichaelDurrant - your edit completely changes the meaning of the question. I don't think the question here was whether .s are valid characters in file names (it's quite obvious they're valid chars). – don_crissti Apr 04 '16 at 19:46
  • @don_crissti yes given the question had been closed I was seeing if it could be reworded as a different question. – Michael Durrant Apr 04 '16 at 20:49

2 Answers2

15

They are valid and you can use them but yes, there are disadvantages.

  • A period is often used in regular expressions to represent a single character.

  • A period in filenames is often used as the standard separator between filename and extensions.

  • A period at the start of a filename is used to indicate configuration and/or hidden files.

For these reasons using periods in filenames for other purposes often leads to issues down the road with other command line functions and other tools and frameworks not expecting them and not working correctly.

2

Periods by themselves have no meaning, but what follows the period may have meaning to programs that look at the file suffix. For that, look at /etc/mailcap and /etc/mime.types

Some implementations of ls can sort by suffix as well, e.g.

ls -lX

for GNU coreutils.

Thomas Dickey
  • 76,765
  • 1
    Interesting—if you use the US order, use periods, and sort by suffix and then by name, you end up with correctly sorted dates: 3 wrongs make a right! – Dan Getz Apr 03 '16 at 15:21
  • If I want names vs dates to sort, I'd just ensure that the timestamps work out (using touch), or making the names begin with a yyyymmdd pattern (no punctuation at all). But OP gave no hints for usage. – Thomas Dickey Apr 03 '16 at 15:24