File size

All about user-defined episode / movie format expressions
Post Reply
nickodemos
Posts: 10
Joined: 20 Dec 2015, 15:54

File size

Post by nickodemos »

I am a person who catalogs multiple movies but tend to have the size on the end of the folders to help differentiate between them.

The Female Animal (1958)(VHSRip)(1.36)
The Female Animal (1958)(VHSRip)(856)

Is there a way to place the site as in the example above to the end of a folder through Filebot?

Was also wondering about how to get riptypes like VHSRip, LaserRip, URip, Unknownrip types added so that filebot can then use them.
User avatar
rednoah
The Source
Posts: 20463
Joined: 16 Nov 2011, 08:59

Re: File size

Post by rednoah »

1.
There's many ways... this is one of them:

Code: Select all

{file.length()/1e6 as int}
2.
If {tags} or {source} doesn't work, you can use the matchAll function on the filename. There's plenty of example in the forums.
:idea: Please read the FAQ and How to Request Help.
nickodemos
Posts: 10
Joined: 20 Dec 2015, 15:54

Re: File size

Post by nickodemos »

rednoah wrote: 1.
There's many ways... this is one of them:

Code: Select all

{file.length()/1e6 as int}
2.
If {tags} or {source} doesn't work, you can use the matchAll function on the filename. There's plenty of example in the forums.
1.
This helped out a great deal. The 1e6 was a bust since it gave bytes and that was not what I was looking for. I did end up using {"${file.length()/1024/1000}"} but as you can see it gives me to much information. Is there a way to remove everything after the period?

The Walk (2015)(HDRip)(1473.989458984375)/The.Walk.(2015).480p.HDRip.XviD.AC3.2.0-EVO

I tried using the round option I found in another thread about ratings but can't seem to get that to work out.
User avatar
rednoah
The Source
Posts: 20463
Joined: 16 Nov 2011, 08:59

Re: File size

Post by rednoah »

file.length() is the size in bytes, 1e6 is 1.000.000, and as int means as Integer, so no decimals.
:idea: Please read the FAQ and How to Request Help.
nickodemos
Posts: 10
Joined: 20 Dec 2015, 15:54

Re: File size

Post by nickodemos »

rednoah wrote:file.length() is the size in bytes, 1e6 is 1.000.000, and as int means as Integer, so no decimals.
Yes I understand that. I even mentioned it in my thanks for giving it to me. Just was wondering about trying to get that round option to work with this or think you can point to me an example of how regex works with FileBot.
User avatar
rednoah
The Source
Posts: 20463
Joined: 16 Nov 2011, 08:59

Re: File size

Post by rednoah »

1.
Round:

Code: Select all

{(file.length()/1e6).toFloat().round()}
2.
Groovy Regex:
http://naleid.com/blog/2008/05/19/dont-fear-the-regexp
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 20463
Joined: 16 Nov 2011, 08:59

Re: File size

Post by rednoah »

The latest revision adds convenience bindings for querying the filesize: {bytes}, {megabytes} and {gigabytes}
:idea: Please read the FAQ and How to Request Help.
yocreoquesi
Posts: 4
Joined: 29 Apr 2020, 11:13

Re: File size

Post by yocreoquesi »

The bindings {bytes} {megabytes} and {gigabytes} are no longer INT on the latest Filebot version (tested with 4.9.4)
kim
Power User
Posts: 1218
Joined: 15 May 2014, 16:17

Re: File size

Post by kim »

maybe you find what you need ?

Code: Select all

{bytes.properties}
e.g.

Code: Select all

{bytes.value}
{bytes.MB}
{bytes.k}
{bytes.g}
{bytes.GB}
{bytes.KB}
{bytes.m}
User avatar
rednoah
The Source
Posts: 20463
Joined: 16 Nov 2011, 08:59

Re: File size

Post by rednoah »

{bytes} is not longer a Number object, but you can get the long value (int won't work for large file size values) like so if you want to use it for mathematical operations:

Code: Select all

bytes.toLong()

Code: Select all

(bytes as long)

:?: What is your use case? Which mathematical operation do you need?


If you want a rounded decimal value for a specific file size unit, then this has gotten easier:

Code: Select all

megabytes.round(1)
or

Code: Select all

bytes.MB.round(1)


:!: Note that {megabytes} and {gigabytes} were always String values (i.e. number formatted to 1 decimal and unit) from the beginning. The new FileSize type aims to fix these inconsistencies.
:idea: Please read the FAQ and How to Request Help.
nickodemos
Posts: 10
Joined: 20 Dec 2015, 15:54

Re: File size

Post by nickodemos »

Nice to hear this.
Post Reply