思想之翼 当前离线
上尉
评分人数
apang 当前离线
上将
@echo off pushd "D:\数据\" for /f "delims=" %%a in ('dir /b *.txt') do ( for /f "usebackq delims=" %%b in ("%%a") do ( if not defined a echo,%%b>$ set "a=%%b" ) setlocal enabledelayedexpansion echo,!a!>>$ endlocal set "a=" & move $ "%%a" ) pause复制代码
TOP
pcl_test 当前离线
荣誉版主
gawk "NR==1;END{print}" a.txt复制代码
DAIC 当前离线
中将
sed -i -n "1p;$p" "D:\数据\*.txt"复制代码
慕夜蓝化 当前离线
四级士官
@echo off&setlocal enabledelayedexpansion for %%i in (d:\数据\*.txt) do ( (set/p str=<"%%i"&echo,!str! for /f %%a in ('type "%%i"^|find /v /c ""') do ( set/a n=%%a-1 call :skip !n! "%%i" )) >%temp%\$ move /y %temp%\$ "%%i" ) pause&exit :skip if %1 leq 0 goto :eof for /f "skip=%1 tokens=1,* delims=[]" %%i in ('type "%~2"^|find /v /n ""') do ( echo,%%j&goto :eof )复制代码
happyxxdhaha 当前离线
二级士官
@echo off pushd d:\数据 for /f "delims=" %%i in ('dir /a-d /b *.txt') do ( call :sub "%%~i">$ move $ "%%~i" ) popd goto:eof :sub set/p start=<"%~1" for /f "usebackq delims=" %%i in ("%~1") do ( set end=%%i ) echo,%start% echo,%end%复制代码