Aries的IT部落格

技术交流和分享

桌面文件分类批处理

一键归类桌面杂乱无章的文件

@echo off
setlocal enabledelayedexpansion

:: 设置桌面路径
set desktopPath=%USERPROFILE%\Desktop

:: 切换到桌面路径
cd /d %desktopPath%

:: 遍历桌面上的文件
for %%A in (*.*) do (
    :: 获取文件扩展名
    set ext=%%~xA
    set ext=!ext:~1!
    
    :: 创建以文件类型命名的文件夹
    if not exist "!ext!" mkdir "!ext!"
    
    :: 移动文件到相应的文件夹
    move /y "%%A" "!ext!\"
)

echo 桌面文件已整理完成。
pause

Powered By Z-BlogPHP 1.7.2

Mail to:hhesong@126.com. Copyright elecccom.cn.Some Rights Reserved.冀ICP备18030769号-1