Problem with replace. MissingMethodException

Any questions? Need some help?
Post Reply
dipstick
Posts: 6
Joined: 12 Nov 2017, 05:17

Problem with replace. MissingMethodException

Post by dipstick »

System Information:
OS Name Microsoft Windows 10 Pro
Version 10.0.15063 Build 15063
Other OS Description Not Available
OS Manufacturer Microsoft Corporation
System Name HAPPY-JOY-BOX
System Manufacturer System manufacturer
System Model System Product Name
System Type X86-based PC
System SKU To Be Filled By O.E.M.
Processor Intel(R) Core(TM)2 Quad CPU Q8200 @ 2.33GHz, 2336 Mhz, 4 Core(s), 4 Logical Processor(s)
BIOS Version/Date American Megatrends Inc. 1605, 11/26/2008
SMBIOS Version 2.5
Embedded Controller Version 255.255
BIOS Mode Legacy
BaseBoard Manufacturer ASUSTeK Computer INC.
BaseBoard Model Not Available
BaseBoard Name Base Board
Platform Role Desktop
Secure Boot State Unsupported
PCR7 Configuration Binding Not Possible
Windows Directory C:\WINDOWS
System Directory C:\WINDOWS\system32
Boot Device \Device\HarddiskVolume1
Locale United States
Hardware Abstraction Layer Version = "10.0.15063.502"
User Name Happy-Joy-Box\desig_000
Time Zone Pacific Standard Time
Installed Physical Memory (RAM) 4.00 GB
Total Physical Memory 3.22 GB
Available Physical Memory 0.99 GB
Total Virtual Memory 3.78 GB
Available Virtual Memory 1.05 GB
Page File Space 576 MB
Page File C:\pagefile.sys
Device Encryption Support Reasons for failed automatic device encryption: TPM is not usable, PCR7 binding is not supported, Hardware Security Test Interface failed and device is not InstantGo, Un-allowed DMA capable bus/device(s) detected, Disabled by policy, TPM is not usable
Hyper-V - VM Monitor Mode Extensions No
Hyper-V - Second Level Address Translation Extensions No
Hyper-V - Virtualization Enabled in Firmware No
Hyper-V - Data Execution Protection Yes


How did you install FileBot?
Sorry, I don't remember.

Hello, and welcome to my first post. Thank you in advance to anyone choosing to help. Please be patient with me, since I'm not advanced in this area. I feel compelled to note however that I'm not a novice either. Using Pulover's Macro Creater GUI I have recently coded to extract about 35 pieces of info from IMDB movie pages. It was more difficult than I anticipated, but I was able to figure it out.

I'm a little surprised that I'm having this much trouble figuring out “replace” in FileBot. It works perfectly in some instances, while other times it gives me a file name that begins with “MissingMethodException”, which I researched, but I'm afraid it's a little above my pay grade.

Please consider these three movies that I've renamed with FileBot:

1. Anti Matter (2016) 6.6 105min 1080p 2ch [Science Fiction]
2. Einstein's God Model (2016) 5.9 88min 1080p 6ch [Thriller, Drama, Science Fiction]
3. Infinity Chamber (2016) 7.1 103min 1080p 6ch [Science Fiction, Thriller]

I used this expression:

{n.replace(':',' - ')} ({y}) {rating} {minutes}min {vf} {af} {genres}

Suppose that for some reason I want to replace the first word in each movie name with “Auntie”. I accomplish this like so:

{n.replace('Anti','Auntie').replace('Einstein','Auntie').replace('Infinity','Auntie')}

It works perfectly to change the movie names into this:

Auntie Matter
Auntie's God Model
Auntie Chamber

Also “{n.replace(':',' - ')}” works perfectly to replace colons in the name. So why can't I use the same syntax to replace “Science Fiction” with “SciFi” when retrieving genres? In my limited capacity this seems fairly straightforward. Wouldn't that be accomplished like so?:

{genres.replace('Science Fiction','SciFi')}

Unfortunately this gives me file names a thousand characters long, that begin with “MissingMethodException”. This syntax as a template produces the same result when trying to replace things in year, minutes and others. I've also played around with replaceAll, with no luck. To quote rednoah, aren't we “talking about replacing characters in a String. That's no RegEx required. Does it matter where the String came from? n ... name, t ... episode title, fn ... filename, etc.”?

As usual I'm probably missing something obvious, and I'll feel embarrassed when someone points it out.

Take care, and thanks.
Google is your friend. It tells you what to do so you don't have to think. :!:
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Problem with replace. MissingMethodException

Post by rednoah »

n is a String object. genres is a List object. The method String.replace(String, String) is defined for Strings but not Lists, hence MissingMethodException.

:idea: Replace A with B for the n String object:

Code: Select all

n.replace('A', 'B')
:idea: Replace A with B for each String object that is in the genres List:

Code: Select all

genres*.replace('A', 'B')
Alternatively, call List.toString() and then do replace() on the resulting String object:

Code: Select all

genres.toString().replace('A', 'B')
:idea: Please read the FAQ and How to Request Help.
dipstick
Posts: 6
Joined: 12 Nov 2017, 05:17

Re: Your Help

Post by dipstick »

Thank you so much, and yes I'm a little embarrassed. Your explanation and examples were spot-on and prompt. Keep fighting the good fight.
Google is your friend. It tells you what to do so you don't have to think. :!:
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Problem with replace. MissingMethodException

Post by rednoah »

Stay strong in the struggle. ;)
:idea: Please read the FAQ and How to Request Help.
Post Reply