I need copy certain files (that satisfy some condition) from directory in another directory, but I have a problem , that every time I copy the files into the folder with shutil.copy
or shutil.copy2
it creates me the .~lock
files, so I'm not able to perform some other functions on this folder
my function to copy the specific files from one folder to another:
def copy_files(path):
path_input = "%input//" % path
path_output="%output//" % path
for i in os.listdir(path_input):
f=os.path.join(path, i)
if f.endswith("t.house.csv"):
shutil.copy(f, path_output) #or shutil.copy2(f, path_output)
So my questions: why it happens and how I can avoid creating of ~lock
files? and if I can't avoid, with which methods I can get rid of them?
if one of the files that I copy is open, it will create corresponding ~lock
file in the folder of destination! so, maybe it's not the best and smartest way to fix this bug, but by making sure that there are no open files, I can avoid the creating of ~lock
files