import os import click import shutil @click.command() @click.argument('eventid', default='') def checkfolder(eventid): original_working_directory = os.getcwd() new_networked_directory = r'\\192.168.88.99\\Bizgaze\\port6003\\wwwroot\\_files\\' # change to the networked directory os.chdir(new_networked_directory) for dirpath, dirnames, files in os.walk('.\\ALL_UNQ\\' + eventid + '/'): if os.listdir(dirpath)==[]: print("files not found") for root, dirs, files in os.walk('C:\\Users\\Administrator\\Documents\\AI\\runtimecropimages\\unique_1\\' + eventid + '\\'): for file in files: path_file = os.path.join(root, file) shutil.move(path_file, '.\\ALL_UNQ\\' + eventid + "\\") else: print("files found") cmd = "python C:\\Users\\Administrator\\Documents\\AI\\runtimecropimages\\unique_Allunq.py "+ str(eventid) os.system(cmd) checkfolder()