(folderPath, prefix)
fill gaps in numbering of files in folder
    Args:
        folderPath (str): path to folder to search
        prefix (str): prefix of files to fill gap
    Returns:
        None
fill gaps in numbering of files in folder
    Args:
        folderPath (str): path to folder to search
        prefix (str): prefix of files to fill gap
    Returns:
        None
fill gaps in numbering of files in folder Args : folderPath ( str ) : path to folder to search prefix ( str ) : prefix of files to fill gap Returns : None
def fillGaps(folderPath, prefix):
    """fill gaps in numbering of files in folder
    Args:
        folderPath (str): path to folder to search
        prefix (str): prefix of files to fill gap
    Returns:
        None
    """
    fileList = getFilesWithPrefix(folderPath, prefix)         # files sorted ascending order
    fileRegex = re.compile(prefix+'(\d{1,})(.\w+)')

    start = int(fileRegex.search(fileList[0]).group(1))       # start with the minimum number in list
    count = start                                             # count to be incremented during checks for gaps
    max_length = len(fileRegex.search(fileList[-1]).group(1)) # max length of largest number, for padding zeros

    for file in fileList:

        mo = fileRegex.search(file)
        fileNum = int(mo.group(1))

        if fileNum != count:
            newFileName = prefix + '0'*(max_length-len(str(fileNum))) + str(count) + mo.group(2)
            shutil.move(os.path.abspath(file), os.path.abspath(newFileName))

        count += 1
def fillGaps ( folderPath , prefix ) : fileList = getFilesWithPrefix ( folderPath , prefix ) # files sorted ascending order fileRegex = re . compile ( prefix + '(\d{1,})(.\w+)' ) start = int ( fileRegex . search ( fileList [ 0 ] ) . group ( 1 ) ) # start with the minimum number in list count = start # count to be incremented during checks for gaps max_length = len ( fileRegex . search ( fileList [ - 1 ] ) . group ( 1 ) ) # max length of largest number, for padding zeros for file in fileList : mo = fileRegex . search ( file ) fileNum = int ( mo . group ( 1 ) ) if fileNum != count : newFileName = prefix + '0' * ( max_length - len ( str ( fileNum ) ) ) + str ( count ) + mo . group ( 2 ) shutil . move ( os . path . abspath ( file ) , os . path . abspath ( newFileName ) ) count += 1