Problem replacing Forward Slash / in Filenames

All about user-defined episode / movie / file name format expressions
Post Reply
xaeiou
Posts: 15
Joined: 22 Oct 2019, 06:24

Problem replacing Forward Slash / in Filenames

Post by xaeiou »

Hi,

As we know, the forward slash is used quite often on TVDB episode titles. Many people choose to substitute another character, and I want to do that too, but replace it with a similar looking unicode character according to the filter described here:

viewtopic.php?f=5&t=12295

Code: Select all

'<>:"/\\|?*'.replace(
	'<' : '﹤',
	'>' : '﹥',
	':' : 'ː',
	'"' : '“',
	'/' : '⁄',
	'|' : '⼁',
	'?' : '﹖',
	'*' : '﹡',
	'\\': '∖'
)
So I'd like to re-visit the issue of forward slashes in filenames (for reference of those interested you can refer here):

viewtopic.php?p=13418#p13418

Where the good advice is given by rednoah about forward slashes being interpreted as path separators.

The problem is my "replace" of '/' : '⁄' doesn't seem to be working at all in a real world example. I'm wondering if I'm running up against a hard-coded safety net in filebot or java or somewhere, I can't seem to find where.

It works for me if I use the test code above, but when I run this against an actual TVDB entry such as:

https://thetvdb.com/series/the-diary-of ... es/7710232

The episode name is a good one for testing purposes :D : "22/7: 8+3=?"

Code: Select all

$ cat ~/bin/unicode.groovy
{sxe} {t.replace(
        '<' : '﹤',
        '>' : '﹥',
        ':' : 'ː',
        '"' : '“',
        '/' : '⁄',
        '|' : '⼁',
        '?' : '?',
        '*' : '﹡',
        '\\': '∖'
)}
Viz: (sorry there are some options maybe extraneous to this discussion, but I want to present it precisely as I'm using it so it can be reproduced):

Code: Select all

$ filebot -version
FileBot 4.9.2 (r8046) / OpenJDK Runtime Environment 15 / Linux 4.15.0-88-generic (amd64)
$ filebot --action test -rename -non-strict -unixfs -r --file-filter f.video "/home/user/samba/mklinks/diary" --db TheTVDB --format /home/user/bin/unicode.groovy --output "/home/user/output" --q "The Diary of our Days"
* Consider using --mode interactive to enable interactive mode
Rename episodes using [TheTVDB] with [Airdate]
Lookup via [The Diary of our Days]
Fetching episode data for [22/7]
[TEST] from [/home/user/samba/mklinks/diary/S00E01.mkv] to [/home/user/output/0x01 22 7ː 8+3=?.mkv]
Processed 1 file
The forward slashes get output as space. I am expecting the rename to be "0x01 22⁄7ː 8+3=?.mkv" here, not "0x01 22 7ː 8+3=?.mkv". The same thing happens if I use a very simple format expression such as '{sxe} {t}' or '{n}' I can't seem to get the "/" from TVDB. Not saying it's filebot for sure, just that I'm confused about where it's getting removed :?

Any suggestions how to further look what's happening to the "/" ?

On the off chance this is specific to my install, but I'd be surprised if that was the case:

Code: Select all

FileBot 4.9.2 (r8046)
JNA Native: 6.1.0
MediaInfo: 20.08
7-Zip-JBinding: 16.02
Tools: fpcalc/1.5.0 mkvpropedit/19.0.0
Extended Attributes: OK
Unicode Filesystem: OK
Script Bundle: 2020-12-01 (r724)
Groovy: 3.0.6
JRE: OpenJDK Runtime Environment 15
JVM: 64-bit OpenJDK 64-Bit Server VM
CPU/MEM: 12 Core / 32 GB Max Memory / 44 MB Used Memory
OS: Linux (amd64)
HW: Linux 4.15.0-88-generic #88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
CPU/MEM: Intel(R) Xeon(R) CPU E5-1650 v3 
DATA: /home/user/.filebot
Package: DEB
License: FileBot License X (Valid-Until: 2069-10-22)
Done ヾ(@⌒ー⌒@)ノ
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Problem replacing Forward Slash / in Filenames

Post by rednoah »

Top-level bindings such as {t} strip / slash implicitly, among other sanitation operations. However, you can use {episode.title} to access the raw value, which may contain / slash, may be infinitely long, etc.
:idea: Please read the FAQ and How to Request Help.
xaeiou
Posts: 15
Joined: 22 Oct 2019, 06:24

Re: Problem replacing Forward Slash / in Filenames

Post by xaeiou »

rednoah wrote: 21 Dec 2020, 02:22 Top-level bindings such as {t} strip / slash implicitly, among other sanitation operations. However, you can use {episode.title} to access the raw value, which may contain / slash, may be infinitely long, etc.
That works perfectly thank as always for your fast response.

I'll add a note with appropriate warnings to my post in the "share your format expression" thread.
cuneglas
Posts: 11
Joined: 10 Jun 2018, 05:54

Re: Problem replacing Forward Slash / in Filenames

Post by cuneglas »

I have the same problem, but with audio files.

For example, using a song where the artist of the album is composed of more than one artist, (medinfo shows artist1/artist2), using

Code: Select all

{media.albumperformer}
or

Code: Select all

{albumartist}
I always get "artist1 artist2" and so I can't use

Code: Select all

.slash(", ")
or

Code: Select all

replaceAll("/", ", ")
to get something like "artist1, artist2"

What can I do to get the values in raw mode before the sanitation operations?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Problem replacing Forward Slash / in Filenames

Post by rednoah »

I can't think of a way to get around sanitation when using media.*, but music.albumArtist might just work.
:idea: Please read the FAQ and How to Request Help.
cuneglas
Posts: 11
Joined: 10 Jun 2018, 05:54

Re: Problem replacing Forward Slash / in Filenames

Post by cuneglas »

It worked, thank you very much.
As always you are the best.
Post Reply