Loops through a parent directory and nests files within folders that already exists and have matching prefixs
    :param directory: Starting directory

def move_files_to_folders(directory):
    """
    Loops through a parent directory and nests files within folders that already exists and have matching prefixs
    :param directory: Starting directory
    """
    # Generate lists of files and folders in root directory
    files, folders, files_to_move = [], [], []
    for path in os.listdir(directory):
        if os.path.isdir(path):
            folders.append(path)
        elif os.path.isfile(path):
            files.append(path)

    # Loop through folders in root directory
    for path in folders:
        # Generate list of files with same prefix as current folder
        child_files = [f for f in files if f.startswith(path)]
        files_to_move.append((path, child_files))

    # Move child files into parent folder
    for each in files_to_move:
        folder, files = each
        for f in files:
            shutil.move(f, folder)