Export metadata on a folder of tiff images via script?

I have been able to export the metadata of a single tiff image using a script, but I have been unable to perform this on a group of tiff files. The results I see is a metadata file for each individual image. The error message I seem to get using the script below is:
"ERROR: Unable to find overlay, no matches found to unload. Be sure to specify the full path to the filename that you wean to export metadata for."
The image data is good as I said I can process them individually. Here is my latest attempt:
GLOBAL_MAPPER_SCRIPT VERSION=1.00
UNLOAD_ALL
//start Loop
DIR_LOOP_START DIRECTORY="S:\Workfolder\GCP\" FILENAME_MASKS="*.tif" RECURSE_DIR=NO
//Import the file
FILENAME="%FNAME_W_DIR%"
//export the metadata
EXPORT_METADATA METADATA_FILENAME="%DIR%%FNAME_WO_EXT%_GCP.txt"
//Unload the loaded data
UNLOAD_ALL
// End the loop
DIR_LOOP_END
Where am I going wrong?
Thanks
"ERROR: Unable to find overlay, no matches found to unload. Be sure to specify the full path to the filename that you wean to export metadata for."
The image data is good as I said I can process them individually. Here is my latest attempt:
GLOBAL_MAPPER_SCRIPT VERSION=1.00
UNLOAD_ALL
//start Loop
DIR_LOOP_START DIRECTORY="S:\Workfolder\GCP\" FILENAME_MASKS="*.tif" RECURSE_DIR=NO
//Import the file
FILENAME="%FNAME_W_DIR%"
//export the metadata
EXPORT_METADATA METADATA_FILENAME="%DIR%%FNAME_WO_EXT%_GCP.txt"
//Unload the loaded data
UNLOAD_ALL
// End the loop
DIR_LOOP_END
Where am I going wrong?
Thanks
Answers