def iso_name_increment(name, is_dir=False, max_length=<NUM_LIT:8>):
<EOL>if not is_dir and '<STR_LIT:.>' in name:<EOL><INDENT>name, ext = name.rsplit('<STR_LIT:.>')<EOL>ext = '<STR_LIT>'.format(ext)<EOL><DEDENT>else:<EOL><INDENT>ext = '<STR_LIT>'<EOL><DEDENT>for position, char in reversed(list(enumerate(name))):<EOL><INDENT>if char not in string.digits:<EOL><INDENT>break<EOL><DEDENT><DEDENT>base, tag = name[:position+<NUM_LIT:1>], name[position+<NUM_LIT:1>:]<EOL>tag = str(int(tag or <NUM_LIT:0>) + <NUM_LIT:1>)<EOL>if len(tag) + len(base) > max_length:<EOL><INDENT>base = base[:max_length - len(tag)]<EOL><DEDENT>return '<STR_LIT>'.join([base, tag, ext])<EOL>
Increment an ISO name to avoid name collision.

    Example:
        >>> iso_name_increment('foo.txt')
        'foo1.txt'
        >>> iso_name_increment('bar10')
        'bar11'
        >>> iso_name_increment('bar99', max_length=5)
        'ba100'