<reponame>clearlon/BasicSR<gh_stars>0
import os
import glob
import argparse


def ClipImageRename(input_path):
    videos_path = glob.glob(os.path.join(input_path, '*'))
    videos_path.sort()
    for video_path in videos_path:
        imgs_name = os.listdir(video_path)
        imgs_name.sort(key=lambda x:int(x[5:8]))
        for img_name in imgs_name:
            index = int(img_name.split('.')[0][-3:]) - 1
            img_rename = f'frame{index:03d}.png'
            os.rename(os.path.join(video_path, img_name), os.path.join(video_path, img_rename))

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-input_path', type=str, default='', help='')
    args = parser.parse_args()

    # videos_path = glob.glob(os.path.join(args.input_path, 'IMG*'))
    # videos_path.sort()
    # num = 169
    # i = 0
    # for video_path in videos_path:
    #     i += 1
    #     root, video_name = os.path.split(video_path)[0:2]
    #     rename = f'{num + i}/'
    #     rename_path = os.path.join(root, rename)
    #     os.makedirs(rename_path, exist_ok=True)
    #     imgs_path = f'{video_path}/*'
    #     os.system(f'mv {imgs_path} {rename_path}')
    ClipImageRename(args.input_path)

if __name__ == '__main__':
    main()

import os
import glob
import argparse


def ClipImageRename(input_path):
    videos_path = glob.glob(os.path.join(input_path, '*'))
    videos_path.sort()
    for video_path in videos_path:
        imgs_name = os.listdir(video_path)
        imgs_name.sort(key=lambda x:int(x[5:8]))
        for img_name in imgs_name:
            index = int(img_name.split('.')[0][-3:]) - 1
            img_rename = f'frame{index:03d}.png'
            os.rename(os.path.join(video_path, img_name), os.path.join(video_path, img_rename))

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-input_path', type=str, default='', help='')
    args = parser.parse_args()

    # videos_path = glob.glob(os.path.join(args.input_path, 'IMG*'))
    # videos_path.sort()
    # num = 169
    # i = 0
    # for video_path in videos_path:
    #     i += 1
    #     root, video_name = os.path.split(video_path)[0:2]
    #     rename = f'{num + i}/'
    #     rename_path = os.path.join(root, rename)
    #     os.makedirs(rename_path, exist_ok=True)
    #     imgs_path = f'{video_path}/*'
    #     os.system(f'mv {imgs_path} {rename_path}')
    ClipImageRename(args.input_path)

if __name__ == '__main__':
    main()
# videos_path = glob.glob(os.path.join(args.input_path, 'IMG*')) # videos_path.sort() # num = 169 # i = 0 # for video_path in videos_path: #     i += 1 #     root, video_name = os.path.split(video_path)[0:2] #     rename = f'{num + i}/' #     rename_path = os.path.join(root, rename) #     os.makedirs(rename_path, exist_ok=True) #     imgs_path = f'{video_path}/*' #     os.system(f'mv {imgs_path} {rename_path}')