/ is an invalid filename char in Unix/Linux

All about user-defined episode / movie format expressions
Post Reply
Jorm
Posts: 20
Joined: 21 Apr 2021, 08:44

/ is an invalid filename char in Unix/Linux

Post by Jorm »

Hi

So ran into a bug I guess as / is not allowed in filenames under Linux/Unix and I assume MacOS..

Code: Select all

##############################################################
### Processing The.Radiator.Springs.500.5.2013.1080p.BluRay.H264.AAC-RARBG ###
##############################################################
Rename movies using [TheMovieDB]
Auto-detect movie from context [/Storage/Video/Sources/Movies/R/The.Radiator.Springs.500.5.2013.1080p.BluRay.H264.AAC-RARBG/The.Radiator.Springs.500.5.2013.1080p.BluRay.H264.AAC-RARBG.mp4]
[HARDLINK] from [/Storage/Video/Sources/Movies/R/The.Radiator.Springs.500.5.2013.1080p.BluRay.H264.AAC-RARBG/The.Radiator.Springs.500.5.2013.1080p.BluRay.H264.AAC-RARBG.mp4] to [/Storage/Video/Movies/R/The Radiator Springs 500 1/2 (2014)/The Radiator Springs 500 1/2 (2014) - 1080p.mp4]
[HARDLINK] from [/Storage/Video/Sources/Movies/R/The.Radiator.Springs.500.5.2013.1080p.BluRay.H264.AAC-RARBG/The.Radiator.Springs.500.5.2013.1080p.BluRay.H264.AAC-RARBG.2_Eng.srt] to [/Storage/Video/Movies/R/The Radiator Springs 500 1/2 (2014)/The Radiator Springs 500 1/2 (2014) - 1080p.eng.srt]
[HARDLINK] from [/Storage/Video/Sources/Movies/R/The.Radiator.Springs.500.5.2013.1080p.BluRay.H264.AAC-RARBG/The.Radiator.Springs.500.5.2013.1080p.BluRay.H264.AAC-RARBG.3_Eng.srt] to [/Storage/Video/Movies/R/The Radiator Springs 500 1/2 (2014)/The Radiator Springs 500 1/2 (2014) - 1080p.eng.1.srt]
Processed 3 files
It will create some funny results in the UI under interactive mode

Code: Select all

             ┌──HARDLINK / INDEX──────────────────────────────────────────────────────────────────────────────────────────┐              
             │[x] The.Radiator.Springs.500.5.2013.1080p.BluRay.H264.AAC-RARBG.mp4         =>  2 (2014) - 1080p.mp4        │              
             │[x] The.Radiator.Springs.500.5.2013.1080p.BluRay.H264.AAC-RARBG.2_Eng.srt   =>  2 (2014) - 1080p.eng.srt    │              
             │[x] The.Radiator.Springs.500.5.2013.1080p.BluRay.H264.AAC-RARBG.3_Eng.srt   =>  2 (2014) - 1080p.eng.srt    │              
             │ ────────────────────────────────────────────────────────────────────────────────────────────────────────── │              
             │                                                                                         <Select> <Cancel>  │              
             └────────────────────────────────────────────────────────────────────────────────────────────────────────────┘         
Jorm
User avatar
rednoah
The Source
Posts: 19917
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: / is an invalid filename char in Unix/Linux

Post by rednoah »

Should work by default:

Code: Select all

$ filebot -rename *.mp4 --db TheMovieDB -non-strict --format "{plex.name}" --action TEST --log INFO
[TEST] from [The.Radiator.Springs.500.5.2013.mp4] to [The Radiator Springs 500½ (2014).mp4]

But the Any-ASCII transliteration seems to introduce ½ => 1/2 in your format code:

Code: Select all

$ filebot -rename *.mp4 --db TheMovieDB -non-strict --format "{plex.name.ascii()}" --action TEST --log INFO
[TEST] from [The.Radiator.Springs.500.5.2013.mp4] to [The Radiator Springs 500 1/2 (2014).mp4]

I can't think of an easy solution... We can't just strip the / characters because we can't distinguish between the intended / unintended ones.


You'd have to build your format path component by path component, e.g.

Code: Select all

{ny.ascii().slash(' ')}/{plex.name.ascii().slash(' ')}



EDIT:

FileBot r8432 introduces File.ascii() which internally applies String.ascii() path component by path component and ensures that no new path components are introduced.
:idea: Please read the FAQ and How to Request Help.
Jorm
Posts: 20
Joined: 21 Apr 2021, 08:44

Re: / is an invalid filename char in Unix/Linux

Post by Jorm »

Ah get why it happens, but would it not be good thing to check for invalid chars before the final write to the filesystem, don't you check it in your code?
User avatar
rednoah
The Source
Posts: 19917
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: / is an invalid filename char in Unix/Linux

Post by rednoah »

Jorm wrote: 13 May 2021, 09:23 Ah get why it happens, but would it not be good thing to check for invalid chars before the final write to the filesystem, don't you check it in your code?
If your code generates a file path /a/b/c/d.txt then - based on that information alone - FileBot cannot know which / is intended and which / is not intended. All the top-level bindings such as {n} and {t} strip / internally so it can't accidentally sneak into the final destination path, but if your code generates / then FileBot can't just strip that away, because generating destination paths with lots of / in the path is what you want to do.
:idea: Please read the FAQ and How to Request Help.
Post Reply