本帖最后由 WHY 于 2022-9-1 14:42 编辑
- @echo off
- setlocal enabledelayedexpansion
- REM 删除第1行,倒数第1行
-
- for /f "skip=1 delims=" %%i in ('dir /b /a-d *.pdf') do (
- if defined file echo;del "!file!"
- set "file=%%i"
- )
- pause
复制代码
- @echo off
- setlocal enabledelayedexpansion
- REM 删除第1/3/5行,倒数第1/3/5行
-
- for /f %%i in ('dir /b *.pdf ^| find /c /v ""') do (
- set /a n=%%i+1, n1=n-1, n3=n-3, n5=n-5
- )
- for %%i in (1,3,5,!n1!,!n3!,!n5!) do set _%%i=1
-
- for /f "delims=" %%i in ('dir /b *.pdf') do (
- set /a i+=1
- if not defined _!i! echo;del "%%i"
- )
- pause
复制代码
|