from pathlib import Path import cv2 import sys import os originalRootPath = '/home/paulo/Área de Trabalho/PLDs - Original' organizedRootPath = '/home/paulo/Área de Trabalho/PLDs Separada' raizOriginal = Path(originalRootPath) pathImgs = raizOriginal.rglob('*.jpg') dictOrig = {} for path in pathImgs: str = path.as_posix() relativePath = str.replace(originalRootPath, '.') fileName = os.path.basename(path) if fileName in dictOrig: print('Duplicated filename in the original dataset') print(fileName) exit(0) dictOrig[fileName] = relativePath raizOrganizado = Path(organizedRootPath) pathImgs = raizOrganizado.rglob('*.jpg') dictOrganizado = {} listPaths = [] for path in pathImgs: str = path.as_posix() relativePath = str.replace(organizedRootPath, '.') fileName = os.path.basename(path) if fileName in dictOrganizado: print('Duplicated filename in the organized dataset') print(fileName) exit(0) dictOrganizado[fileName] = relativePath listPaths.append(relativePath.replace(fileName,'')) setPaths = set(listPaths) print('unrar e "./Sequences Test/All - 1000 frames/All_QRIDR.rar" "./Sequences Test/All - 1000 frames/All_QRIDR/"') print('unrar e "./Sequences Test/All - 1000 frames/All_VXUSD.rar" "./Sequences Test/All - 1000 frames/All_VXUSD/"') print('unrar e "./Sequences Train - 6616 Frames/Images_train.rar" "./Sequences Train - 6616 Frames/Images/"') for str in setPaths: print("mkdir -p " + str) dictCp = {} for key, value in dictOrig.items(): try: print("cp \'" + value + "' " + "'" + dictOrganizado[key] + "'") dictOrganizado.pop(key) except KeyError: print('Key not found in the organized dataset') print(fileName) exit(0) print('rm -rf "./Sequences Test/All - 1000 frames/All_QRIDR/"') print('rm -rf "./Sequences Test/All - 1000 frames/All_VXUSD/"') print('rm -rf "./Sequences Train - 6616 Frames/Images/"') if(len(dictOrganizado.keys()) > 0): print("Error: some organized images were not found")