in reply to Caught in a loop

This seems like one of those cases where a better understanding of the overall task would really help. Based on the fragments in the OP when I read it, the basic idea seems to be something like this:

On a continuous basis (running constantly):

  1. Check G:/Input to see if there are any files whose names are 1 to 36 characters long and have a ".txt" extension.
  2. For each file detected in step 1, check G:/Output for ... (?)
  3. ?? ... (something involving a particular file (subset) in G:/Output? or something involving the current file from G:/Input if there is no matching file in G:/Output? or something for every pairing of files in the two directories?)

If your overall goal for this app can be described in such terms, there may be much better ways to do this than nested for loops. But I don't know what to suggest, because I don't know what you really want to do.