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.
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 "{(num) ([0-9]* )}" ([0-9]* )(\+)([ 0-9]*)} ") "{num([ 0-9]*)} " newname) .groups( ) int(cg[ 1])) count)+ int(cg[ 5])) int(cg[ 3]))
330,332c330,331
< count = `count`
< cr = re.compile(
< "|{(num)
---
> cr = re.compile(
> "|{num([0-9]*) ?\+ ?([0-9]+)}")
334,337c333,338
< cg = cr.search(
< 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(
< 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(
< if cg[3] != '': count = count.zfill(
<
< newname = cr.sub(count, newname)
---
> sn = int(cg[2])
> newname = cr.sub(str(count + sn).zfill(fn), newname)