Page 1 of 1

(ask) How to rename movie with filesize in gigabytes

Posted: 25 Jan 2016, 11:30
by randy030991
Hi Iam newbie
How to rename movie with filesize in gigabytes?

eg:

I Origins (1958)

become: I Origins (2.1)

or : I Origins (2.1 Gb)


Thanks for your help

Re: (ask) How to rename movie with filesize in gigabytes

Posted: 25 Jan 2016, 11:58
by rednoah
The latest revision does have the {megabytes} and {gigabytes} bindings.

With FileBot v4.6.1 and older you can always use file.length() to calculate the numbers you want though:
viewtopic.php?f=5&t=3283

Re: (ask) How to rename movie with filesize in gigabytes

Posted: 25 Jan 2016, 12:02
by randy030991
rednoah wrote:The latest revision does have the {megabytes} and {gigabytes} bindings.

With FileBot v4.6.1 and older you can always use file.length() to calculate the numbers you want though:
viewtopic.php?f=5&t=3283
so its like this?:
{n} {gigabytes}

or
{n} file.length({gigabytes})

sorry iam so newbie about code programming
thanks

Re: (ask) How to rename movie with filesize in gigabytes

Posted: 25 Jan 2016, 15:35
by rednoah
More like this:

Code: Select all

{(file.length()/1e9).toFloat().round(1)} GB

Re: (ask) How to rename movie with filesize in gigabytes

Posted: 13 Mar 2016, 00:54
by nickodemos
I am the one who asked in the other thread that rednoah linked to. He helped out a great deal in getting me straightened out with my coding.

What I ended up with was two different codes. One for a MB file up to a GB and one for over a GB.

For files from 1-999MB I use this:

Code: Select all

({(file.length()/1024/1024).toFloat().round()})
For files over 1000MB I use:

Code: Select all

({(file.length()/1024/1048).toFloat().round()})
Not sure why the math is different but it works for when I add file size to the folders.

Re: (ask) How to rename movie with filesize in gigabytes

Posted: 13 Mar 2016, 06:41
by rednoah
So you're switching your format for each file!? Just a condition that formats files differently depending on their file size.

Code: Select all

{file.length() < 1e6 ? (file.length()/1e6).toFloat().round() + ' MB' : (file.length()/1e9).toFloat().round(1) + ' GB'}

Re: (ask) How to rename movie with filesize in gigabytes

Posted: 09 May 2020, 18:47
by AbedlaPaille
rednoah wrote: 13 Mar 2016, 06:41 So you're switching your format for each file!? Just a condition that formats files differently depending on their file size.

Code: Select all

{file.length() < 1e6 ? (file.length()/1e6).toFloat().round() + ' MB' : (file.length()/1e9).toFloat().round(1) + ' GB'}
Is this supposed to display 0.8 GB ? Thought it'd use MB if inferior to 1 GB.

Is there a way to use this on folders and have the linked srt going in the same 3 GB folder instead of a 0 MB one?

Re: (ask) How to rename movie with filesize in gigabytes

Posted: 10 May 2020, 04:12
by rednoah
AbedlaPaille wrote: 09 May 2020, 18:47 Is there a way to use this on folders and have the linked srt going in the same 3 GB folder instead of a 0 MB one?
It should work by default, if you use {bytes}, or preferrably {gigabytes} in this case, unless it's an orphaned subtitle, in which case FileBot can't implicitly use the primary video file.


Alternatively, you can always do your own size calculations based on the parent folder or something like that:

Code: Select all

{folder.files.sum{ it.length() }}

Re: (ask) How to rename movie with filesize in gigabytes

Posted: 16 May 2020, 01:40
by AbedlaPaille
Wow we can make stuff happen depending on how many files are in? Cool.

{gigabytes} works great, just wanted 700 MO displayed instead of 0.7 GO in those < 1GO files.