Page 1 of 1

/ is an invalid filename char in Unix/Linux

Posted: 12 May 2021, 08:50
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

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

Posted: 12 May 2021, 09:43
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.

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

Posted: 13 May 2021, 09:23
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?

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

Posted: 13 May 2021, 09:49
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.