Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Delete directories in folder is not working after folder is updated
So I'm having an automated test that is deleting all the projects inside Projects folder.

folder = myPath\Projects\Project1

The test executes like this:


The code for deleteProjectsFromFolder is this:

        for the_file in os.listdir(folder):
            file_path = os.path.join(folder, the_file)
                if os.path.isfile(file_path):
                elif os.path.isdir(file_path): shutil.rmtree(file_path)
            except Exception as e:
First delete projects from folder works but the second one after new project is created does not delete the directories(projects) anymore. What should I do in this case?Are there some other solutions for this?
Show more of the code. The problem is likely originating elsewhere.
I guess everything else is related to the automation framework itself. The problem I guess the program sits in that directory and after the folder is updated it does not know anymore to execute delete(folder) again.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Why doesn't gc delete an object without forcing a garbage collection call? AlekseyPython 5 170 Mar-19-2019, 02:10 AM
Last Post: micseydel
  Scanning files to rename other files in the same folder. msd1391 6 161 Mar-11-2019, 07:19 PM
Last Post: msd1391
  Problems parsing /proc folder anddontyoucomebacknomore 2 124 Mar-06-2019, 09:16 PM
Last Post: DeaD_EyE
  Not Able To Delete First Node From Python Linked List ribena1980 8 152 Mar-05-2019, 03:14 PM
Last Post: ichabod801
  dictionary of dictionaries, to be updated Skaperen 2 118 Mar-03-2019, 07:15 AM
Last Post: Skaperen
  How to get a random item from a list, print it and delete it? giorgosmarga 3 144 Feb-22-2019, 05:33 PM
Last Post: Yoriz
  Accessing Files In A Folder asilverg 1 93 Feb-15-2019, 08:08 AM
Last Post: buran
  Delete multiple files using file extention sumncguy 2 169 Jan-23-2019, 03:05 AM
Last Post: snippsat
  Executing func() from a different folder ebolisa 2 160 Jan-14-2019, 10:18 AM
Last Post: ebolisa
  opening a file from a windows desktop folder- error opening file Charan007 1 209 Dec-06-2018, 11:50 AM
Last Post: buran

Forum Jump:

Users browsing this thread: 1 Guest(s)