Page 1 of 1

Noob here, needs help with CLI command

Posted: 27 Jun 2019, 19:55
by gKxFF
Hey there.

I'm trying to rename a whole bunch of folders, into something more "readable".

So, without explaining too much, the directory where all the folders reside, is like this:

Code: Select all

/home/user/Movies/This.Is.A.Movie.1999.BluRay.x264-GROUP
/home/user/Movies/This.Is.Also.A.Movie.2001-BluRay.x264-GROUPP
and so on.

I would like to rename the folders, so that it'll be like:

Code: Select all

/home/user/Movies/This Is A Movie (1999)/This.Is.A.Movie.1999.BluRay.x264-GROUP
/home/user/Movies/This Is Also A Movie (2001)/This.Is.Also.A.Movie.2001-BluRay.x264-GROUPP
Can anybody help me with this? It would be especially nice, if the words like these start with a capital letter (upper-case):

Code: Select all

III, II, IV, The, Of, And, At, Vs, A, An, But, Nor, For, On, So, Yet
and so on :)

Thanks.

EDIT:
Another "important" thing - I would like only for the folders to be renamed, not the files inside them :).

Re: Noob here, needs help with CLI command

Posted: 27 Jun 2019, 20:03
by kim
try this:

Code: Select all

/home/user/Movies/{plex.name}/{fn}
if you REALLY need all words "start with a capital letter"

Code: Select all

/home/user/Movies/{plex.name.upperInitial()}/{fn}

Re: Noob here, needs help with CLI command

Posted: 27 Jun 2019, 20:39
by gKxFF
Thanks for the answer, but how do I put it into a CLI command?

I tried running

Code: Select all

filebot -rename /home/user/Movies/* --db "TheMovieDB" --format "{plex.name.upperInitial()}/{fn}"
But that messed up things a lot. Made the right directories, except they're all sub-folders, plus the command added sub-folders that just includes the subtitles. Like:

Code: Select all

/home/user/Movies/This.Is.A.Movie.1999.BluRay.x264-GROUP/This Is A Movie (1999)/
/home/user/Movies/This.Is.A.Movie.1999.BluRay.x264-GROUP/This Is A Movie (1999).Eng/(subs)

Re: Noob here, needs help with CLI command

Posted: 28 Jun 2019, 00:59
by kim
looks like plex is f*cking the subs :( ?

better use this then:

Code: Select all

{ny.upperInitial()}/{fn}
e.g.

Code: Select all

filebot -rename -r /home/user/Movies -non-strict --db TheMovieDB --output "/home/user/Movies/" --format "{ny.upperInitial()}/{fn}"
btw: you can revert the rename (history)

Re: Noob here, needs help with CLI command

Posted: 28 Jun 2019, 23:37
by gKxFF
Hey again Kim.

Running your command, gives somewhat unexpected results.

It's now:

Code: Select all

/home/user/Movies/This Is A Movie (1999)/allTheFilesCorrectlyNamed
/home/user/Movies/This.Is.A.Movie.1999.BluRay.x264-GROUP/(empty)
Which is not the result I was hoping for :(

I'm still looking for:

Code: Select all

/home/user/Movies/This Is A Movie (1999)/This.Is.A.Movie.1999.BluRay.x264-GROUP/(allFilesNamedAsOriginal)
EDIT:
Bunch of edits, sorry. 01:43AM gmt+1

Re: Noob here, needs help with CLI command

Posted: 29 Jun 2019, 00:36
by kim
so video folder + files renamed ok ?
and subs is not ?
sounds like your subs are badly named or something ?

test with subs named same as video file and in same dir as video

testing on windows this works

Code: Select all

filebot -rename -r "D:\temp" -non-strict --db TheMovieDB --output "D:\temp" --format "{ny.upperInitial()}/{fn}" --action test

Re: Noob here, needs help with CLI command

Posted: 29 Jun 2019, 10:19
by gKxFF
No, they aren't correctly renamed :/

The folder structure, after running your command is:

Code: Select all

/home/user/Movies/This Is A Movie (1999)/(allTheFilesCorrectlyNamed)
/home/user/Movies/This.Is.A.Movie.1999.BluRay.x264-GROUP/(empty folder)
I would like it to be:

Code: Select all

/home/user/Movies/This Is A Movie (1999)/This.Is.A.Movie.1999.BluRay.x264-GROUP/(allTheFilesCorrectlyNamed)
So that the This.Is.A.Movie.1999.BluRay.x264-GROUP is a sub-folder to This Is A Movie (1999)

Does that make sense? And also, thanks so much for the help so far :)

Re: Noob here, needs help with CLI command

Posted: 29 Jun 2019, 10:40
by rednoah
Here's what I get:

Code: Select all

filebot -rename -r . --output . --format "{ny}/{fn}" --action TEST --db TheMovieDB -non-strict

Code: Select all

Rename movies using [TheMovieDB]
Auto-detect movie from context: [Avatar.2009.mkv]
[TEST] from [Avatar.2009.mkv] to [Avatar (2009)/Avatar.2009.mkv]
Processed 1 files

Re: Noob here, needs help with CLI command

Posted: 29 Jun 2019, 11:09
by gKxFF
Yes, and me too.

Using your example, I would like it to be:

Code: Select all

Rename movies using [TheMovieDB]
Auto-detect movie from context: [Avatar.2009.mkv]
[TEST] from [Avatar.2009.mkv] to [Avatar (2009)/Avatar.2009/Avatar.2009.mkv]
Processed 1 files
So that the folder name, parent to the mkv file, is the same name as the mkv file, e.g. Avatar.2009


Edit
Running the command:

Code: Select all

filebot -rename -r . --output . --format "{ny.upperInitial()}/{fn}/{fn}" --action TEST --db TheMovieDB -non-strict
Works, BUT! It does create extra folders because the SRT files aren't named the same as the other files :/
Like so:

Code: Select all

/home/user/m/local/Movies/Movie Title (2008)/Movie.Title.2008.1080p.BluRay.x264-GROUP.en/Movie.Title.2008.1080p.BluRay.x264-GROUP.en.srt
Is there any way to exclude the SRT files? So that it doesn't "recognize" them, when renaming? Because of Plex, I kind of need the ".en.srt" part of the subtitle, so that it gets registered properly as an English subtitle

Re: Noob here, needs help with CLI command

Posted: 29 Jun 2019, 12:12
by rednoah
Can you post the command and console output that you're getting please? So can see exactly what you're doing and what's not working, so I can find a solution for you?

Re: Noob here, needs help with CLI command

Posted: 29 Jun 2019, 13:45
by gKxFF
Here's the command:

Code: Select all

filebot -rename -r . --output . --format "{ny.upperInitial()}/{fn}/{fn}" --action TEST --db TheMovieDB -non-strict
Here's the output:

Code: Select all

https://pastebin.com/ZDT1ea4g

Re: Noob here, needs help with CLI command

Posted: 29 Jun 2019, 18:26
by kim
try this:

Code: Select all

{f.isSubtitle() ? (ny-subt).upperInitial() + '/' + fn-subt : ny.upperInitial() + '/' + fn}/{fn}
btw: weird output path you want

Re: Noob here, needs help with CLI command

Posted: 29 Jun 2019, 21:41
by gKxFF
I tried running

Code: Select all

filebot -rename -r . --output . --format "{f.isSubtitle() ? (ny-subt).upperInitial() + '/' + fn-subt : ny.upperInitial() + '/' + fn}/{fn}" --action TEST --db TheMovieDB -non-strict
Gave me this output:

Code: Select all

https://pastebin.com/YR0vEXqk
Which has the same problem. It still creates a separate folder for the subtitles, e.g.

Code: Select all

[TEST] from [/home/plex/m/local/Movies/Mississippi.Burning.1988.REMASTERED.1080p.BluRay.x264-SiNNERS/Mississippi.Burning.1988.REMASTERED.1080p.BluRay.x264-SiNNERS.en.srt] 
to 
[/home/plex/m/local/Movies/Mississippi Burning (1988)/Mississippi.Burning.1988.REMASTERED.1080p.BluRay.x264-SiNNERS.en/Mississippi.Burning.1988.REMASTERED.1080p.BluRay.x264-SiNNERS.en.srt]

Re: Noob here, needs help with CLI command

Posted: 29 Jun 2019, 23:31
by kim
{subt} converts 2 letter lang to 3 .. not good here :(

Code: Select all

{f.isSubtitle() ? (ny-subt).upperInitial() + '/' + fn.replaceAll(/\.\w*$/) : fn}/{fn}
Mississippi Burning (1988)\Mississippi.Burning.1988.REMASTERED.1080p.BluRay.x264-SiNNERS\Mississippi.Burning.1988.REMASTERED.1080p.BluRay.x264-SiNNERS.en.srt
only works if e.g.
.XX.srt format

Re: Noob here, needs help with CLI command

Posted: 30 Jun 2019, 03:58
by rednoah
I have distilled a test case:

Code: Select all

filebot -rename -r . --output . --format "{ny}/{fn}/{fn}" --action TEST --db TheMovieDB -non-strict
Rename movies using [TheMovieDB]
Auto-detect movie from context: [Avatar.2009.mkv]
[TEST] from [Avatar.2009.mkv] to [Avatar (2009)/Avatar.2009/Avatar.2009.mkv]
[TEST] from [Avatar.2009.25fps.eng.srt] to [Avatar (2009)/Avatar.2009.25fps.eng/Avatar.2009.25fps.eng.srt]
Processed 2 files
Presumably, this is not working as expected, since the video and the subtitle file end up in different folders.


Problem: "Folder name same as the file name" doesn't work, since it's not what you want, since you want "Folder name same as the file name, if it's a movie file, but if it's a subtitle file, use guess the corresponding video file name, and use that as folder name instead" which is obviously more intricate.


Easy Solution: Use --format "{plex}" or --format "{ny}/{fn}" (if you really want to keep the original name) and call it a day.


Hard Solution: Write intricate format code that does exactly what you want. I'd go with the Easy Solution though, since it's probably gonna be more than good enough for your particular use case.

Re: Noob here, needs help with CLI command

Posted: 30 Jun 2019, 11:12
by gKxFF
Kim: Thanks so much for your help so far!
I tried running:

Code: Select all

filebot -rename -r . --output . --format "{f.isSubtitle() ? (ny-subt).upperInitial() + '/' + fn.replaceAll(/\.\w*$/) : fn}/{fn}" --action TEST --db TheMovieDB -non-strict
Which gave me this result:

Code: Select all

https://pastebin.com/bHP1Qfuw
Not sure what to make of it to be honest.

But when I remove the --action TEST part:

Code: Select all

filebot -rename -r . --output . --format "{f.isSubtitle() ? (ny-subt).upperInitial() + '/' + fn.replaceAll(/\.\w*$/) : fn}/{fn}" --db TheMovieDB -non-strict
It gives me all sorts of Java-related errors:

Code: Select all

https://pastebin.com/YmGkJQxt

Rednoah:
I'm more inclined to go the hard way :). I have a huge 30TB+ library, all set up this way, I'm not about to change that :) (and sorry for being such a nuisance).
That's the reason I'm so persistent with my weird way of sorting things...
But thanks a lot for your help so far, I guess I'll either have to do this manually, or find another solution.


Edit:
I found somewhat of a solution.... To run a command, that renames all the files as the parent folder name:

Code: Select all

rename 's/(.*)\/.*\./$1\/$1./' */*
And then run the simple Filebot command:

Code: Select all

filebot -rename -r . --output . --db TheMovieDB --format "{ny.upperInitial()}/{fn}/{fn}" -non-strict
And then rename the SRT files by running:

Code: Select all

rename 's/\.srt/\.en\.srt/' */*/*
But if there's any way to do all of this "within" Filebot, that would be preferable to me :)

Re: Noob here, needs help with CLI command

Posted: 30 Jun 2019, 20:34
by kim
I forgot "ny.upperInitial() + '/' + " part and remove subt
and maybe it's better to hardcode the lang codes:

Code: Select all

{f.isSubtitle() ? ny.upperInitial() + '/' + fn.replaceAll(/\.(en|eng)$/) : ny.upperInitial() + '/' + fn}/{fn}

Re: Noob here, needs help with CLI command

Posted: 01 Jul 2019, 09:00
by rednoah
Here's an idea. Since FileBot will automatically try to find the corresponding video file when using MediaInfo bindings such as {resolution} on subtitle files, you might be able to get the video file name via the {media} binding:

Code: Select all

{media.FileName}
:arrow: viewtopic.php?f=5&t=4285

Re: Noob here, needs help with CLI command

Posted: 02 Jul 2019, 20:02
by gKxFF
kim wrote: 30 Jun 2019, 20:34 I forgot "ny.upperInitial() + '/' + " part and remove subt
and maybe it's better to hardcode the lang codes:

Code: Select all

{f.isSubtitle() ? ny.upperInitial() + '/' + fn.replaceAll(/\.(en|eng)$/) : ny.upperInitial() + '/' + fn}/{fn}
This seems to work! I have only tested on a single folder, but it seems to work out very well :). I'll edit this post, when I've tested it on a larger scale.

Thank you so much Kim (and rednoah) for the great help and persistence :)!!

For anyone, who should be curious to try it out:

Code: Select all

filebot -rename -r . --output . --db TheMovieDB --format "{f.isSubtitle() ? ny.upperInitial() + '/' + fn.replaceAll(/\.(en|eng)$/) : ny.upperInitial() + '/' + fn}/{fn}" -non-strict