Using ":" in file names

Discussion in 'macOS' started by ElectricMan5, May 23, 2009.

  1. ElectricMan5 macrumors regular

    Joined:
    Jul 22, 2008
    #1
    Is there anyway we can enable the use of colons :)) in file names?

    It drives me crazy that we can't use them... But there has to be some system file that lets me change what I can use and what I can't. Thanks!
     
  2. r.j.s Moderator emeritus

    r.j.s

    Joined:
    Mar 7, 2007
    Location:
    Texas
    #2
    No, that's part of how the system handles paths.
     
  3. larkost macrumors 6502a

    Joined:
    Oct 13, 2007
    #3
    There is an odd little dance that the file system does around the ":" and "/" characters. The former is used through the POSIX APIs (think: command line), and the latter is used in the Finder. They are actually the same character (two expressions of the same thing).
     
  4. J the Ninja macrumors 68000

    Joined:
    Jul 14, 2008
    #4
    Ok, here's the deal as I've understood it. The Classic Mac OS used colon to divide directories in file paths. However, UNIX has always used the slash. What's OS X to do.....well, it uses slashes. Finder, in an attempt to make the two worlds match, secretly changes the colons you type into slashes, and displays the slashes in the file system as colons.

    I may be wrong on a few details, but I think that is the gist of it.
     
  5. mslide macrumors 6502a

    Joined:
    Sep 17, 2007
    #5
    Just don't do it. Technically, it is possible to create a file with a ":" in it, using Terminal. It is a special character and needs to be escaped with a "\".

    $ touch foo\:.c
    $ ls

    You'll see it there, however, it won't show up correctly in Finder. Delete it by doing a "rm foo\:.c".

    OSX is a POSIX operating system. I can't remember the exact posix rules regarding what can and cannot be used in a filename, but it is a good idea to just never use a ":" in a filename, or any other character that requires it to be escaped. I don't even use spaces in filenames for the same reason.

    Yes, the ":" was used as the path separator character but only for the classic mac os. OSX is now posix, so like all unix operating systems, the "/" is now used.

    If I have a file where I would normally want a ":" in it, I'll use a "-" or "," instead. Those characters are no problem.
     
  6. bstreiff macrumors regular

    Joined:
    Feb 14, 2008
    Location:
    Austin, TX, USA
    #6
    You can use colons in filenames:
    Code:
    bstreiff@fenchurch:~$ echo "blah" > "foo:bar"
    bstreiff@fenchurch:~$ ls -l foo:bar
    -rw-r--r--  1 bstreiff  bstreiff  5 May 24 10:02 foo:bar
    Just expect lots of problems when you attempt to use files like that (Finder displays the file as "foo/bar", and I can imagine plenty of applications not being able to open the file successfully).
     
  7. ElectricMan5 thread starter macrumors regular

    Joined:
    Jul 22, 2008
    #7
    Oi. Thanks for the answers guys, except I couldn't understand any of that UNIX stuff :eek:

    I mostly want to use them in folder names, such as Halo 2: Combat Evolved and WoW: WotLK. I know that using a "-" can work, but I get tired of them sometimes.

    Thanks for your help :)
     

Share This Page