先给出用 bat+sed 可直达6种结果的一行流代码...
结果-1- @echo off &cd /d "d:\data1" &for /f "delims=" %%a in ('dir /b/o-s *.txt^|sed -n "1,50p" ') do copy /y "%%a" "d:\data2\"
复制代码
结果-2- @echo off &cd /d "d:\data1" &for /f "delims=" %%a in ('dir /b/o-s *.txt^|sed -n "51,$p" ') do del /q "%%a"
复制代码
结果-3- @echo off &cd /d "d:\data1" &for /f "delims=" %%a in ('dir /b/os *.txt^|sed -n "1,50p" ') do copy /y "%%a" "d:\data2\"
复制代码
结果-4- @echo off &cd /d "d:\data1" &for /f "delims=" %%a in ('dir /b/os *.txt^|sed -n "51,$p" ') do del /q "%%a"
复制代码
结果-5- @echo off &cd /d "d:\data1" &for /f "delims=" %%a in ('dir /b/os/-c *.txt') do if "%%~za" equ "1024" (copy /y "%%a" "d:\data2\")
复制代码
结果-6- @echo off &cd /d "d:\data1" &for /f "delims=" %%a in ('dir /b/o-s/-c *.txt') do if "%%~za" neq "1024" (del /q "%%a")
复制代码