windows 屏保图片保存(保存bat.运行即可,修改电脑用户名)

@echo off
:: 使用 UTF-8 编码,确保路径识别正确
chcp 65001 >nul

set "sourceDir=C:\Users\Troy\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets"
set "targetDir=C:\Users\Troy\Pictures"

:: 获取日期
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /value') do set "dt=%%I"
set "today=%dt:~0,4%-%dt:~4,2%-%dt:~6,2%"

if not exist "%targetDir%" mkdir "%targetDir%"

echo 正在从 Assets 文件夹提取大于 1MB 的图片...
set /a count=1

:: 开启变量延迟扩展
setlocal enabledelayedexpansion

for /f "delims=" %%f in ('dir /b /a-d "%sourceDir%"') do (
set "fullPath=%sourceDir%\%%f"

:: 获取文件大小(字节)
for %%A in ("!fullPath!") do set "fsize=%%~zA"

:: 只有大于 1,048,576 字节 (1MB) 才处理
if !fsize! GTR 1048576 (
set "newName=LockScreen_%today%_!count!.jpg"

:: 检查重名并复制
copy /y "!fullPath!" "%targetDir%\!newName!" >nul
echo [成功] 已保存: !newName! (大小: !fsize! 字节)
set /a count+=1
)
)

echo.
echo ============================================
echo 提取完成!请检查 C:\Users\Troy\Pictures
echo ============================================
pause

posted @ 2026-01-16 10:12  adao  阅读(1)  评论(0)    收藏  举报