import json
import numpy as np
import cv2
import os
import argparse
import pathlib
import os.path

"""
This code is used to rename whole folder 
"""

# set input and output folders
pathin ="img4"
pathout = "img_f"
f_type = "*png"

if os.path.exists(pathin) and os.path.exists(pathout):
    input_path = pathlib.Path(pathin)
    label_paths_sorted = sorted(list(input_path.glob(f_type)))
    print(label_paths_sorted)
    for image_path in label_paths_sorted:
        print('converting: {}'.format(os.path.basename(image_path)))
        pthin = pathin + "/{}"  .format(os.path.basename(image_path))
        pthout = pathout + "/f4{}"  .format(os.path.basename(image_path))
        print(pthin)
        os.rename(pthin, pthout)
else:
    print("Folders do NOT exist")