Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在一个文件夹中有大约 100 个长文件名的 .txt 文件,我需要在文件中搜索字符串“4096”的第一个实例,然后从每个文件中返回整行并将其复制到输出 .txt 文件中.
我是批处理语法的新手,所以一个完整的解决方案会很棒,
提前致谢。
干得好:
@echo off setlocal enabledelayedexpansion for %%a in (*.txt) do ( set found=false for /f "skip=2 tokens=*" %%b in ('find "4096" "%%a"') do ( if "!found!"=="false" ( echo %%b >>output.txt set found=true ) ) )