awk: illegal field $(), name "OUT_FOLDER" input record number 1, file
/home/dir/input/TAB1.a1.001.txt source line number 1

I tried several iterations to output the files and failed miserably after a few hours...It must be some simple thing that I overlooked or not knowing how to do it. Any suggestions would be highly appreciated. Thank you.

Thanks @steeldriver it's very helpful. Now I just need to figure out how to add basename command into awk. :D
– Molly_KMar 23 at 12:49

@Molly_K you could probably use the awk split function to implement a basename e.g. n = split(FILENAME,p,"/"); print p[n]. But perhaps you should consider use -execdir in place of -exec in the find command instead.
– steeldriverMar 23 at 14:33

Thank you @seeldriver, I followed your suggestion using split(FILENAME,p."/"); print p[n]. But I was not able to get it to work. I got the following error message awk: bailing out at source line 1. I understand this is not part of the original question, I am happy to open another question if you think that's more appropriate. The full command line I used was ` find "$BASE" -type f -iname "*sefile.txt" -exec awk '{print toupper($0) >> (ENVIRON["OUT_FOLDER"] (n = split(FILENAME,p,"/"); print p[n]) "_cap.txt")}' {} +` I also tried to put split before print toupper($0), also did not work.
– Molly_KMar 25 at 14:36

@Molly_K print p[n] was just for illustration: to construct a filename from the value you would sue something more like {n = split(FILENAME,p,"/"); print toupper($0) >> ENVIRON["OUT_FOLDER"] p[n] "_cap.txt"}'. But I recommend you use -execdir` if possible so that FILENAME will be relative to its parent directory instead.
– steeldriverMar 25 at 14:44

Thank you @steeldriver. I was able to execute the awk command under the proper directory using -execdir. Also, moving n = split(FILENAME,p,"/") in front of print toupper works as well. Thank you very much for the quick response. I read up the man page for find and am continuing my reading on the awk book by Dale Dougherty.
– Molly_KMar 25 at 16:16