move files within a directory to another directory

4.1k views Asked by At

I am currently working on a Raspberry Pi that is capturing images 24/7. I am wanting to delete the files in a directory A (where the images are stored) without deleting the directory itself. I know that shutil.rmtree will remove the directory(A) but I have other programs sending files to that directory(A) all the time. So the instant a file is trying to come into a directory A and it does not exist it crashes my Raspberry Pi.

I know that I can move the files within a directory(A) to another directory(B). However using the shutil.copytree or shutilmove only copies the files to my directory B. It does not "cut" the files just copy them.

The only reason I want to do this is because file space is limited and the Raspberry Pi is running 24/7.

Any ideas would be helpful.

0

There are 0 answers