mardi 12 mai 2020

Is there a way to set an operation to a boolean, then create an if statement to do something if that operation was done?

So I'm moving a lot of files within folders to the layer above all the folders. Essentially what I need to happen is if a file was removed from a folder (to the layer above), then delete the folder it was removed from. Something like:

    for file in files:
        print(file)
        shutil.move(file, downloads_path)
        moved = shutil.move(file, downloads_path)
            if moved is True:
                os.remove(downloads_folder_path)

Aucun commentaire:

Enregistrer un commentaire