You actually got everything right but the details are missing.
Here's a script that works it may have some bugs with paths containing spaces haven't tested it):
@echo off
SETLOCAL
SET fileList=%1
SET notFoundFile=%2
REM clear the not found file
type NUL > %notFoundFile%
FOR /R %%d IN (.) DO (
FOR /F "tokens=*" %%a IN (%fileList%) DO (
ECHO processing "%%~fd\%%a"
IF NOT EXIST "%%~fd\%%a" ECHO %%~fd\%%a Not found >> %notFoundFile%
)
)
Usage
The command searches for files recursively from the current directory. It accepts two parameters: the first is the full path to the file containing the list of files to search and the second is the full path to the file where the not found files are recorded.
For example, assume:
- the batch above is stored in the file findmissing.cmd in the directory c:\batchdir
(i.e. the batch file's full path is c:\batchdir\findmissing.cmd)
- The list of files to find is listed in the file: c:\batchdir\listimagescopy.txt
- The result file containing the list of "not found" files will be: c:\batchdir\notfound.txt
Then in order to search for the files in the directory c:\searchdir and all its subdirectories you'd need to CD to that directory and run:
c:\searchdir> \batchdir\findmissing.cmd \batchdir\listimagescopy.txt \batchdir\notfound.txt
What's going on
Batch files store the first parameter (\batchdir\listimagescopy.txt in the example) in the argument variable %1, the second parameter (\batchdir\notfound.txt in the example) is stored in %2 (further parameters if they existed would be stored %3 %4, etc.)
SET fileList=%1
SET notFoundFile=%2
Stores the command line parameters in local (because of the SETLOCAL above) environment variables. This is just a convenience to have nicer variable names. Environment variables are extended (accessed) in the batch with e.g. %fileList%.
type NUL > %notFoundFile%
Clears the contents the contents of the "not found" file or creates a new zero length file if it doesn't exist. This is important because we'll be appending to this file and don't want the results from different runs to be there.
FOR /R %%d IN (.) DO (
Starts at the current directory and recursively list all the directories by matching them with (.) .
The directory names are placed in the for loop variable %%d
FOR /F "tokens=*" %%a IN (%fileList%) DO (
Does what you described in your question, it takes each line in fileList and stores it in the for variable %%a
Now the interesting part %%d contains the current directory in the loop including the trailing "." so for example:
%%d = "c:\searchdir\."
Accessing the variable with the ~f option removes the trailing '.'
%%~fd = "c:\searchdir"
%%a contains the name of one of the files you are searching say:
%%a = "image001.jpg"
Then:
%%~fd\%%a = "c:\searchdir\image001.jpg"
These lines should now be obvious:
ECHO processing "%%~fd\%%a"
IF NOT EXIST "%%~fd\%%a" ECHO %%~fd\%%a Not found >> %notFoundFile%
but I'll explain them anyway; the first just tells you what the batch is doing. It can be removed to speed things up (quite substantially.)
The second tests whether the file %%~fd\%%a exists and if not appends (that's the >>, using > overwrites) the string "%%~fd\%%a Not found" to the file %notFoundFile%, after expanding the variables so you get the actual name of the file not found in your file.
You can make the internal loop nicer by placing the content of %%~fd\%%a in a variable instead of repeating the pattern, but you'll need delayed expansion see here and here