{num} starts from 0 instead of 1

Bug #560324 reported by Viper
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
pyRenamer
Confirmed
Undecided
Unassigned

Bug Description

According to help pop-up message {num} should start from 1.

Revision history for this message
Viper (viper-sovsem) wrote :

Proposed fix:
{num} - starts from 1, as described, and this equivalent to {num+1}
{num+10} - starts from 10.

Also reduced number exceptions raised during work, previous code generates exception for every file when {num} pattern isn't used. Using if should get better performance in such cases.

pyrenamer_filefuncs.py
330,332c330,331
< count = `count`
< cr = re.compile("{(num)([0-9]*)}"
< "|{(num)([0-9]*)(\+)([0-9]*)}")
---
> cr = re.compile("{num([0-9]*)}"
> "|{num([0-9]*) ?\+ ?([0-9]+)}")
334,337c333,338
< cg = cr.search(newname).groups()
< if len(cg) == 6:
<
< if cg[0] == 'num':
---
> cg = cr.search(newname)
> if cg:
> cg = cg.groups()
> fn = 0
> sn = 1
> if cg[0] or cg[1]:
339,342c340,341
< if cg[1] != '': count = count.zfill(int(cg[1]))
< newname = cr.sub(count, newname)
<
< elif cg[2] == 'num' and cg[4] == '+':
---
> fn = int(cg[0] or cg[1])
> if cg[2]:
344,347c343,344
< if cg[5] != '': count = str(int(count)+int(cg[5]))
< if cg[3] != '': count = count.zfill(int(cg[3]))
<
< newname = cr.sub(count, newname)
---
> sn = int(cg[2])
> newname = cr.sub(str(count + sn).zfill(fn), newname)

Revision history for this message
Viper (viper-sovsem) wrote :
Revision history for this message
Michael Murphy (mmstick) wrote :

This should be default behavior has humans read from 1, not 0.

Changed in pyrenamer:
status: New → Confirmed
Revision history for this message
Shnoulle (shnoulle) wrote :

And if i need a start by 0 ?

The help sentence need to be fixed or add -# {num3-1}

If you set start at 1 : we CAN NOT start at 0. Actually we can start at 0 or 1.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.