注意先备份文件,问题一的批处理:
@echo off
setlocal enabledelayedexpansion
set /a m=5
for %%a in (*.txt) do (
for /f "usebackq delims=" %%i in ("%%~a") do (
set /a n+=1
if !n! leq !m! (echo %%i>>"新的TXT.txt") else (echo %%i>>"%%~na.new"))
copy "%%~na.new" "%%~a" & del "%%~na.new")
问题二:
@echo off
setlocal enabledelayedexpansion
for /f "usebackq delims=" %%i in ("1.txt") do (set /a n+=1 & set "s!n!=%%i")
for /f "usebackq delims=" %%i in ("2.txt") do (set /a m+=1 & set "s!m!=%%i")
if !n! leq !m! (
for /l %%i in (1,1,!n!) do (echo !%n%%%i!!%m%%%i!)) else (
for /l %%i in (1,1,!m!) do (echo !%n%%%i!!%m%%%i!)))>"新的TXT.txt"
时间有限,能帮你的就这些了。