Python3 multiprocessing working on the same list of files

So i have this folder that has a bunch of files (images) and i wanna move the files into another directory if certain conditions apply to it.

Now my problem https://snaptube.cam/ is that when one process does move a file… when another process tries to test it, it can’t find it and it throws an error.

I save the files’ names into a list before i start and the processes go through the list to select the files by their names like this

#for i in os.listdir(): do stuff

My question is: can i /should i lock the files until the previous process is done testing it?? and if yes… will the the other processes skip it if they find it locked and will they come back to it later or not?? (since each process is doing its own test and needs to test all the files available).

Also… when i do move a file i want its name to be deleted from the list of files’ names and i want the other processes to be told that the list has been updated and update theirs.

Yes it’s alway’s a good idea to lock ure files since it helps u not making a mess of things also for security reasons. U can alway’s reverse it

Also… when i do move a file i want its name to be deleted from the list of files’ names and i want the other processes to be told that the list has been updated and update theirs.
Is this small or large TOIL? If it just once I would just do it manually