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?

5
  • 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
    Commented Apr 3, 2016 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
    Commented Apr 3, 2016 at 14:51
  • Retitled for reopen Commented Apr 4, 2016 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). Commented Apr 4, 2016 at 19:46
  • @don_crissti yes given the question had been closed I was seeing if it could be reworded as a different question. Commented Apr 4, 2016 at 20:49

2 Answers 2

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.

0
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.

2
  • 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
    Commented Apr 3, 2016 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. Commented Apr 3, 2016 at 15:24

Not the answer you're looking for? Browse other questions tagged .