Can't you use something like this:
fileList = findFiles(glob: 'tests***1.xml') fileDir = fileList[0].path.minus(fileList[0].name)
I tested it and it works for me.
Thanks,
It looks good as a workaround, except in some edge cases where matched filename as a string is also found in the directory path.