I want to copy all files from a directory to a new folder. But there are multiple files in subfolders and i just want to copy all files with "NFL_V2" in it.
I am using python and tried this with os and shutil.
Dont know how to look for files with these letters and als if .find is the correct way-
Thanks!
UPDATE I could solve this issue by using glob.glob()
Find the fixed code below!
source_dir = r"C:\folders\SHP_20211001"
dest_dir = r"C:\folders\DKM_NFL"
keyword = "NFL_V2"
for fname in glob.glob(source_dir+"/**", recursive=True):
if keyword in fname:
shutil.copy(fname, dest_dir)
print("Copied " + fname + " to new folder")