Because in your code, the for statement parses the text line by line. So, if you use the code in to filter records in the specified directory, how many lines are there in your %dati%_9.txt, the find %dati%_6.txt /v /i "%%a">>%dati%_5.txt statement will be executed that many times. You should change to another filtering solution to fundamentally solve the problem.
Just now during the testing process, it was found that in the option of not searching certain specific paths under the advanced search, you can only select y, but not n. Selecting n prompts that it is an invalid operation. This is because you did not make a jump when selecting n; after the selection is completed, a lot of temporary files have been generated before pressing any key to execute the next step. This belongs to the operation being too early, and it should start generating only after pressing any key; and after the search is completed, the path name in the success prompt is wrong;
Today I will temporarily test here. I will test comprehensively another day - the code is getting more and more, and it looks a bit difficult, especially when encountering unclear expressions. Please pay attention to modifying the prompt language to make it both concise and accurate, and not let others have misunderstandings.
for /f "tokens=* delims= " %%a in (%dati%_9.txt) do (find %dati%_6.txt /v /i "%%a">>%dati%_5.txt)
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。