Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Currently, I use a YYMMDD-NAME+PAGE name for most of my files. NAME has spaces converted to underscores.

I'd like to use the YYYY-MM-DD date format, but I am not sure how to separate it from the name. A - would look strange if the name started with a number. If I use a _, then it conflicts with the underscore representing a space.

What characters are reasonably safe in file names that would work here? I am on Linux, but I might share files with other people (Windows 7, Mac OS X).

share|improve this question
    
… on Unix, Windows, an Amiga 1000? –  slhck Nov 18 '11 at 10:35
    
Mostly modern Linux. –  queueoverflow Nov 18 '11 at 10:42
    
- symbol is safe to use on windows 7.. may be other modern operating system do same.. you can use minus symbol to separate.. –  Niranjan Kala Nov 18 '11 at 10:48
add comment

2 Answers

up vote 9 down vote accepted

Summary:

  • Windows: anything except ASCII's control characters and \/:*?"<>|
  • Linux, OS-X: anything except null or /

On all platforms it is best to avoid non-printable characters such as the ASCII control-characters.

Windows

In Windows, Windows Explorer does not allow control-characters or \/:*?"<>| You can use spaces. If you use spaces, you will often have to quote the filename when used from the command line (but GUI apps are unaffected so far as I know). Windows filesystem such as NTFS apparently store the encoding with the filename, but UTF-16 is standard.

Linux, OS-X

In Linux and OS-X only / of the printable ASCII set is prohibited I believe. Some characters (shell metacharacters like *?!) will cause problems in command lines and will require the filename to be appropriately quoted or escaped.

Linux filesystems such as ext2, ext3 are character-set agnostic (I think they just treat it more or less as a byte stream - only nulls and / are prohibited). This means you can store filenames in UTF-8 encoding. I believe it is up to the shell or other application to know what encoding to use to properly convert the filename for display or processing.

Conclusion

So you could probably safely use something like (if it weren't so hard to type)

share|improve this answer
    
All in all a good answer, but I'd refrain from using filenames in spaces. Escaping them properly in all contexts is more trouble than it's worth. Notice that Microsoft stopped using space in system directory names. If you need to indicate word boundaries in names, CamelCase works fine. –  Isaac Rabinovitch Sep 6 '12 at 5:55
1  
"C:\Program files (x86)" still exists in Win8 - is that not a system directory? I agree that spaces can cause problems. –  RedGrittyBrick Sep 6 '12 at 9:22
    
It is, but it can be renamed to pretty much anything. Of course, a lot of programs will freak out if you rename it to "]:\foobar", but Windows refers to it as "%programfiles(x86)%" anyway. –  Marcks Thomas Sep 6 '12 at 15:27
    
@RedGrittyBrick Oops. Good point. What I should have said is that MS stopped using names with spaces for newly-invented system directories. –  Isaac Rabinovitch Sep 9 '12 at 3:43
add comment

You could:

  1. replace current underscores with # (proofreader's symbol for space)
  2. underscore to 'section' date from filename (or a second hyphen - easier to type)

Alt-1. initial-caps can replace spaces: YYMMDD-HHMM-FileName.ext or YYMMDD-HHMM_FileName.ext

Minimal characters for clear display, which auto-sorts with padded zeroes for Jan-Sep (& 1st-9th ea mo).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.