Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import os
- import sys
- import time
- filename = str((sys.argv[1]))
- rootdir = filename[:9]
- with open(filename, 'r') as f:
- data = json.load(f)
- inputpath = 'C:\\images\\empty\\'
- outputpath = rootdir + '\\' + rootdir
- try:
- os.mkdir(outputpath)
- print("Directory " , outputpath , " Created ")
- except FileExistsError:
- print(outputpath)
- for dirpath, dirnames, filenames in os.walk(inputpath):
- structure = os.path.join(outputpath, dirpath[len(inputpath):])
- if not os.path.isdir(structure):
- os.mkdir(structure)
- else:
- print("Folder does already exits!")
- time.sleep(5)
- for label in data:
- #print(file['bicycle'])
- for file in label['filenameList']:
- newPath = file.replace(rootdir + '\\', rootdir + '\\' + rootdir + '\\' + label['type'] + "\\")
- print('Moving to ' + newPath)
- try:
- os.rename(file, newPath)
- except:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement