I'm using glob to walk through a directory, and pull files that fit a particular parameter. The trouble I'm running into is a FileNotFoundError partway through the glob:
def collate_files(old_dir, new_dir) -> str:
for subfolder in old_dir.rglob('*.xlsx'):
if subfolder.match("string_title"):
new_dir= new_dir.joinpath(subfolder)
if Path.exists(new_dir):
pass
else:
try:
shutil.copy(subfolder, new_dir, follow_symlinks=True)
except OSError as e:
raise e
Error comes up as:
FileNotFoundError: [WinError 3] The system cannot find the path specified: "\\\\absoute_path_directory\\subfolder\\etc"
I double checked, and the file path exists. What can I do to either fix the OSError or pass over it entirely?