have a folder with hundreds of text files, but only a hand full have the keyword "glossary"in them. I need to find these files and copy them to another folder.
You don't need a batch file to copy a few files.
Instead of fretting about tough details, do what you can do. You can make the results into a list. Right? Then edit the list with Notepad and turn it into a batch file list instead of a loop.
Suppose I had some files with 'man' in the name. The I might get a list for text files like this:
pacman.txt
rayman.txt
mandate.txt
fatmanhop.txt
Using Notepad, I would put a # at the stat of each line and a $ at the end of the line.
#pacman.txt$
#rayman.txt$
#mandate.txt$
#fatmanhop.txt$
Even on a list of up to one hundred items, you can do this rather fast. Humans are like that. I am a human.
Next, I would tell notepad to replace every # with the word 'copy' with a space after it. Then back to top, replace every $ with a space and the target path.
When the above is done, I save may 'list.txt' files as 'list.bat' and run it as a bat file.
The time from concept to finish can be under half an hour.
Or, you can spend another day on loops and debugging.
The method I use is easier to visualize. Because you see it.
And you can do exceptions very easily.