Hi JMarc, > It seems that the thing to do is to keep track of visited directories, like > here for example: > https://stackoverflow.com/questions/36977259/avoiding-infinite-recursion-with-os-walk
Good point. These will be my first lines of Python-code, but I’ll try. I tested this with an artificial symlink cycle and it worked: --- lyxgit/lib/scripts/TeXFiles.py 2019-06-06 19:10:58.000000000 +0200 +++ lyxgit/lib/scripts/TeXFiles.py 2019-06-06 18:59:20.000000000 +0200 @@ -116,7 +116,17 @@ if not os.path.isdir(dir): continue # walk down the file hierarchy - for root,path,files in os.walk(dir): + visited = set() + for root,dirs,files in os.walk(dir, followlinks=True): + # prevent inifinite recursion + recurse = [] + for dir in dirs: + st = os.stat(os.path.join(root, dir)) + key = st.st_dev, st.st_ino + if key not in visited: + visited.add(key) + recurse.append(dir) + dirs[:] = recurse # check file type for file in files: if len(file) > 4 and file[-4:] == file_ext: Regards, Michael