I am trying to get my program to read a list of names from a file (say .txt), then search for those in a selected folder and copy and paste those files to another selected f
Your last section has a problem.
for file in os.listdir(folderPath):
for file in files:
if file in filesToFind:
shutil.copy(file, destination)
The first for
loops over each filename in the directory, which is perfectly understandable.
The second for
is an error, because files
does not exist. What did you intend it to do?