Renaming with a word search inside nfo file

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
screamjojo
Posts: 3
Joined: 01 Feb 2024, 23:18

Renaming with a word search inside nfo file

Post by screamjojo »

Hello,

I've a folder with a mkv file and a nfo file. I would like to search a key word inside the nfo for renaming the mkv file.
I've found

Format: Select all

(model.any{id == it.id && it.ext == 'nfo' && it.f.text =~ /(?i)VFQ/}) {return '.VFQ'})
but it works only if the folder is the input, but if the mkv file is the input the nfo file in the same folder is not taken, can you help me ?
Thanks in advance
User avatar
rednoah
The Source
Posts: 22836
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming with a word search inside nfo file

Post by rednoah »

:?: What is your test case? Please post sample file paths as text and NFO file contents so that we are prototyping your custom format with sample files that actually match your use case.


:?: (A) Maybe like this?

Code: Select all

Avatar.mkv
Avatar.nfo
:?: (B) Maybe like this?

Code: Select all

Avatar.mkv
movie.nfo
:?: (C) Maybe something else?


:?: Maybe something different (A) (B) (C) for each movie folder?

:?: Can we assume that movies are already organized into movie folders with one movie / NFO file per folder?
:idea: Please read the FAQ and How to Request Help.
screamjojo
Posts: 3
Joined: 01 Feb 2024, 23:18

Re: Renaming with a word search inside nfo file

Post by screamjojo »

Hello,
Yes my path is like this :

Code: Select all

Avatar.2009.1080p.mkv
Avatar.2009.1080p.nfo
:?: Can we assume that movies are already organized into movie folders with one movie / NFO file per folder?
Yes exactly, and sometimes with a sample file.

And I only need to rename the mkv because the nfo will not move and will be delete.

Thank you for help
User avatar
rednoah
The Source
Posts: 22836
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming with a word search inside nfo file

Post by rednoah »

1. Select only movie files. See How do I process only specific kinds of files? for details.

2. Rewrite file paths using the following format:

Format: Select all

{ files.any{ it.name =~ /[.]nfo$/ && it.text =~ /(?i)VFQ/ } ? '.VFQ' : null }
:idea: {files} is a built-in binding that gives you the "group by same file name" set of files. So for <name>.mkv it'll give a list of <name>.mkv and <name>.nfo from the same folder.
:idea: Please read the FAQ and How to Request Help.
screamjojo
Posts: 3
Joined: 01 Feb 2024, 23:18

Re: Renaming with a word search inside nfo file

Post by screamjojo »

Thank you it works perfectly !
Post Reply