I'm trying to delete an empty directory that is open in command line. If the directory is empty, is there still a process connected to it? I've been messing with the psutil package, but I haven't been able to find a process connected to the open directory (ie. I can find the name() and cmdline() but I cannot find the open file). I'm trying to accomplish this in python and it has to be automated. I know there are a lot of posts on this topic, but I can't find anything specifically to find the process of an open empty directory or any other way to remove it.
To clarify, I'm using rmtree(filename) and getting PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: filename
EDIT: This only happens when the directory is open in command line. The directory can be removed if opened in windows explorer. I can see that command line is holding the process, but how do I determine which command line process is associated with the open directory in order to kill that process but not others?