INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: PadNumber([Field], 0) Should Be Remove Padding  (Read 2435 times)

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
PadNumber([Field], 0) Should Be Remove Padding
« on: June 03, 2015, 01:17:23 am »

Can you modify PadNumber() to apply default padding with argument 0 (or -1 or something)?

There is currently no way to "unpad" numbers. PadNumber() can only increase padding, not decrease it.  I'd really prefer to see it be bi-directional, but at the least, 0 should remove all the padding, and let you start over.

When I had my calamity this weekend, I discovered something annoying (something else annoying):

* Fill Properties from Filename does not unpad numbers imported for [Episode] and [Season].
* RMCF, of course, does pad those to two digits.

So, when I re-imported, and had to do Fill Properties from Filename on some of them, they picked up [Episode] and [Season] numbers that were padded to two digits.  Annoying.

So, try to undo this for me.  It is easy to test.  Go to your Library and select some TV Show episodes.  Open the Tagging AW, and type this in the [Episode] field box:
=PadNumber([Episode], 3)

Now, undo it.  I hope when you did it, you selected only episodes 1-9 of a series, because then you can use =RemoveLeft([Episode], 2) on them.  I couldn't figure out any other way.  I didn't, of course, have only episodes 1-9 of series, I had a whole pile of them.  A few, because they were part of Documentary series with 3-digit episode numbers, so some were padded to three digits, and I had three "tiers" of RemoveLeft() I had to use.

If there is some other way (which I still haven't thought of), it isn't very intuitive.

PadNumber([Field], 0) should pad them to no padding.  If it isn't super difficult, PadNumber() should be able to both increase and decrease padding.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9159
Re: PadNumber([Field], 0) Should Be Remove Padding
« Reply #1 on: June 03, 2015, 01:42:36 am »

Valid request. Would work for me.

Could counter() have been quicker? Simply replacing the contents instead of manipulating them?

Granted, you would have probably had to do that a series at a time, so quicker? Maybe, maybe not.

6233638

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 5353
Re: PadNumber([Field], 0) Should Be Remove Padding
« Reply #2 on: June 03, 2015, 01:45:35 am »

FormatNumber([Episode,0]) seems to remove padding.
 
I don't disagree with anything you have written though.
It would be far simpler to use PadNumber() to adjust padding size, rather than only being able to increase padding size with the command.
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: PadNumber([Field], 0) Should Be Remove Padding
« Reply #3 on: June 03, 2015, 02:07:18 am »

Valid request. Would work for me.

Could counter() have been quicker? Simply replacing the contents instead of manipulating them?

Granted, you would have probably had to do that a series at a time, so quicker? Maybe, maybe not.

I thought about that. Because it would have required a series at a time, RemoveRight() was faster.  I sorted them by [Episode] and could do it in big blocks to fix multiple series at once.

It would have only taken one "pass" really, if I hadn't had those three-digit episodes.  But, even that wasn't so bad.  Still, I tried the PadNumber() thing thinking it would work (including testing -1, hoping), and none did.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10967
Re: PadNumber([Field], 0) Should Be Remove Padding
« Reply #4 on: June 03, 2015, 03:54:06 am »

So if I change PadNumber to always set the padding to the requested amount, taking into account existing padding and removing if necessary, instead of only adding that much padding, noone would ever complain?
Somehow I think I'm going to break someones workflow..... :)

Just making 0 or -1 behave special is rather inconsistent, and I would rather not go down that route.
Logged
~ nevcairiel
~ Author of LAV Filters

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10967
Re: PadNumber([Field], 0) Should Be Remove Padding
« Reply #5 on: June 03, 2015, 04:14:47 am »

I'll just blame glynor if it blows up.
Changed: The PadNumber() expression will remove existing padding from numbers if a lower padding is asked for.

One caveat: to make this work properly, entirely empty fields will no longer be "padded". Before this change, an empty field would also be padded with zeros ... which seemed kinda weird to me in the first place.
So maybe its not a caveat at all, but an improvement?!? :)

Also, if a field is all padding (or, you know, the number 0, padded), it'll not trim that to empty, but always keep the "0" around. Which is related to the empty field not being padded anymore. Otherwise, PadNumber(PadNumber(0, 3), 0) would not be 0 again, but <empty>, which would also be weird.

All in all, it should behave rather consistently now.
Logged
~ nevcairiel
~ Author of LAV Filters

6233638

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 5353
Re: PadNumber([Field], 0) Should Be Remove Padding
« Reply #6 on: June 03, 2015, 04:36:48 am »

Sounds good.
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: PadNumber([Field], 0) Should Be Remove Padding
« Reply #7 on: June 03, 2015, 07:17:52 am »

Sounds good.

Yep.

FormatNumber([Episode,0]) seems to remove padding.

Ahh, FormatNumber()... Didn't think of that one. Of course.  Oh well.  I think bidirectional PadNumber() makes more sense and is better.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/
Pages: [1]   Go Up