Posts: 15
Joined: Mon Oct 08, 2018 1:09 pm

Name mangling in Samba shares - mapping the dreaded colon!

Sat Nov 10, 2018 5:57 pm

I'm using my Pi as a PVR for recording TV programmes. I have installed Samba to share the directory of recordings so it is accessible by a Windows PC which accesses it as \\pi\sharename\directory\filename.

And I've fallen foul of the dreaded problem that Unix file and directory names can contain characters such as ":" which Windows filenames cannot.

The default configuration of Samba is to "mangle" file/directory names to 8.3 DOS names, which yields some legal but utterly unintelligible names :-) But that's sorted by adding a line "mangled names=no" to the definition of the share in /etc/samba/smb.conf (and restarting Samba).

However it doesn't solve the problem of colons and other "unprintable" characters in filenames. Has anyone solved the problem of how to map them to a printable character such as "." while preserving the rest of the name?

An example is a UNIX file/folder "Britain's Ultimate Pilots: Inside the.../Britain's Ultimate Pilots: Inside the...-20181110-1600-BBC TWO HD.ts". The "..." is a "feature" of the listing in the programme guide and can be ignored (long names get shortened by the broadcaster, with the rest of the programme name continuing in the programme description).

Windows sees the directory as Unix lists it, but can't open the directory. Manually changing the ":" to a "." (in Unix) allows you to go into the directory (so the length of the name and the trailing "..." are not a problem). But then the filename in the directory cannot be opened until you make the same change (in Unix) to the filename.

I see in ... 05_04.html that there is a keyword "mangled map" which can be used for this sort of thing, but I'm not sure how to drive it: they give examples such as "(*.database *.db)" which renames any file which ends ".database" so it is called ".db" when seen by Windows. I thought about "mangled map =(*:* *.*)" but that seems to have no effect.

Posts: 2067
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Name mangling in Samba shares - mapping the dreaded colon!

Sat Nov 10, 2018 7:03 pm

Many years ago you used to be able to do this:

Code: Select all

mangled map =(: _) (\ _)
That should change colon and back slashes to underscores as I think that’s better than the dot for file names and extensions BUT the function has now gone :roll: (depreciated is the term)

Now I think the best bet is to use ... tia.8.html and get that to sort them for you.

:twisted: or get rid of Windows from the network :twisted:
Need Pi spray - these things are breeding in my house...

Posts: 15
Joined: Mon Oct 08, 2018 1:09 pm

Re: Name mangling in Samba shares - mapping the dreaded colon!

Sun Nov 11, 2018 4:32 pm

Thanks for that. I've managed to find another solution in the meantime, which prevents the Unix file containing the illegal characters in the first place. The package I'm using to generate the files and folders (a PVR package that records TV programmes) has an option that I hadn't spotted before (a dialogue box that was too big to fit entirely on the screen!): "Use Windows compatible filenames". That maps things like ":" to "_" as the Unix file and folder are being created.

I'd tried "mangled map" but it had no effect, even using the example in the help page that I posted. Looking at "man smb.conf", that keyword doesn't seem to be implemented in the Pi's implementation of Samba, which agrees with what you said about it being deprecated.

Return to “General discussion”