Filenames being munged in finder

I am using Mojave 10.14.1 (updated) and I have a script that creates a tar file of my work directory.

The name of the resulting tgz file is created from a timestamp and some strings. Once run, the

script properly creates the archive file, and according to 'ls' in a terminal session, the name is

being set correctly, but in the finder it it being displayed differently.


In the terminal session 'ls -l Sites-*' shows this:

...

-rw-r--r-- 1 doug staff 7339538 Nov 25 07:03 Sites-2018-11-25-07:03.tgz

-rw-r--r-- 1 doug staff 7339698 Nov 25 07:48 Sites-2018-11-25-07:48.tgz

-rw-r--r-- 1 doug staff 7339695 Nov 25 11:06 Sites-2018-11-25-11:06.tgz

-rw-r--r-- 1 doug staff 7339369 Nov 25 11:20 Sites-2018-11-25-11:20-bsf.tgz


In the finder, the time portion of the filename, which s/b hh:mm is being

displayed in the finder as mm/ss. Very weird.

This looks like a finder bug to me. I don't think a colon is forbidden ina filename,

but a forward slash is certainly a problem in certain contexts. FYI


Douglas Goodall, Santa Maria, CA US

Replies

This behaviour makes sense, but only when looked at from a historical perspective. On UNIX-based systems the file system uses

/
(forward slash) as the path separator. In contrast, traditional Mac OS used
:
(colon). macOS uses both, depending on the layer at which you’re working. If you’re working in Terminal, you get UNIX behaviour, that is, file names can’t contain forward slash. If you’re working in the Finder, you get traditional Mac OS behaviour, that is, file names can’t contain colon. To make this work the system swaps slashes and colons as the name moves between those layers. So, for example, if you use a UNIX tool like
tar
to create a file
hh:mm.txt
then the Finder will show it as
hh/mm.txt
, and vice versa.

Why does it still work this way? Well, back in the dawn of macOS we tried to remove this behaviour and a lot of folks complained. It’s very common for folks to want to push slashes in file names — specifically when dealing with dates — and removing that feature generated vociferous complaints.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"