lovekix 当前离线
二级士官
for /f "delims=" %%i in ('dir /b /a-d Microsoft-Windows-*') do del /a /f /q %%i复制代码
for /f "delims=" %%a in ('dir /b /a-d ^|findstr /r /v "Microsoft-Windows-"') do ( del %%a复制代码
TOP
路过 当前离线
三级士官
@echo off setlocal enabledelayedexpansion for /f "delims=" %%i in ('dir /b /a-d') do ( set file=%%~i set st=!file:~0,18! if "!st!" neq "Microsoft-Windows-" (del /a /f /q %%i) ) pause exit复制代码
went 当前在线
少校
@echo off cd /d "C:\Windows\servicing\Packages" REM 开头保存字符串,竖线分隔多个 set "save=Microsoft-Windows-|Package" for /f "delims=" %%i in ('dir /b /a-d ^| findstr /b /v "%save:|= %"') do echo %%i pause&exit复制代码
确认后,第五行echo改为del went 发表于 2021-6-15 20:14
@echo off cd /d "C:\Windows\servicing\Packages" REM 开头保存字符串,竖线分隔多个 set "save=Microsoft-Windows- |Package |1 |2 |4" for /f "delims=" %%i in ('dir /b /a-d ^| findstr /b /v "%save:|= %"') do echo %%i pause&exit复制代码
@echo off setlocal enabledelayedexpansion for /f "delims=" %%i in ('dir /b /a-d') do ( set file=%%~i set st=!file:~0,18! if "!st!" neq "Microsoft-Windows-" ( set st=!file:~0,7! if "!st!" neq "Package" ( del /a /f /q %%i ) ) ) pause exit复制代码
@echo off cd /d "C:\Windows\servicing\Packages" for /f "delims=:" %%i in ('findstr /b /n ":list" "%~0"') do for /f "delims=" %%a in ('more +%%i "%~0"') do call set "save=%%save%%:%%a" for /f "delims=" %%i in ('dir /b /a-d ^| findstr /b /v "%save::= %"') do echo %%i pause&exit REM 开头保存字符串,一行一个 :list Microsoft-Windows- Package复制代码
@echo off cd /d "C:\Windows\servicing\Packages" for /f "delims=:" %%i in ('findstr /b /n ":list" "%~0"') do for /f "delims=" %%a in ('more +%%i "%~0"') do call set "save=%%save%%:%%a" for /f "delims=" %%i in ('dir /b /a-d ^| findstr /b /v "%save::= %"') do del %%i pause&exit REM 开头保存字符串,一行一个 :list Microsoft-Windows- Package复制代码
if "!st!" neq "Package" ( del /a /f /q %%i复制代码
qixiaobin0715 当前离线
大校
@echo off set var="Package Microsoft-Windows-" cd /d "C:\Windows\servicing\Packages" for /f "delims=" %%i in ('dir /b /a-d ^| findstr /bv %var%') do del /a /f /q "%%i" pause复制代码