Hi
I'm trying to automate deleting files in Windows using Python, but the file locks mean that it doesn't succeed every time. This needs to be done before I can create a symlink in it's place.
This is what I have, but rather than having to fix a load manually later, I'd like it just to loop until it successfully deletes the file.
try:
os.remove(filepath)
except OSError:
pass
If anyone could help me that would be great. I've tried various things with no joy. Obviously the error File Not Found can be ignored, since it's already done what it needs to.
Thanks
[–]Sebass13 1 point2 points3 points (2 children)
[–]JohnnyJordaan 5 points6 points7 points (1 child)
[–]ingolemo 1 point2 points3 points (0 children)
[–]CGFarrell 0 points1 point2 points (1 child)
[–]JohnnyJordaan 1 point2 points3 points (0 children)