惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - sunwugang

026.数据库Sqlserver解决远程连接问题 C# SqlSuger C# DataTableToList C# 开机自启动批处理bat文件 C# 将exe可执行程序设置为开机自启动 025.数据库下载&win10安装注意事项 024 数据库信息查询 + 连接串配置 C# Json操作 C# TextBox 新增文本并定位光标 C# base64转pdf + 上传至指定url C# 猜字谜 C# 闲来笔记 StringHelper--字符串左右添加指定字符 Vue学习笔记72--element ui Vue学习笔记71--histroy模式+hash模式 Vue学习笔记70--全局前置-路由守卫 + 后置路由守卫 + 独享守卫 + 组件内守卫 Vue学习笔记69--activated + deactivated Vue学习笔记68--缓存路由组件 Vue学习笔记67--编程式路由导航
批处理自动删除指定文件夹中的文件夹以及文件
sunwugang · 2025-03-21 · via 博客园 - sunwugang
@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion

set "target_folder=D:\测试文件夹"
set "success=0"

echo 正在尝试删除文件夹: "%target_folder%"

rem 检查文件夹是否存在
if exist "%target_folder%\*" (
    echo 发现目标文件夹,开始删除...
    rd /s /q "%target_folder%"
    if !errorlevel! equ 0 (
        echo 成功删除文件夹
        set "success=1"
    ) else (
        echo 错误代码 [!errorlevel!]: 删除失败,可能是权限不足或文件被占用
    )
) else (
    echo 文件夹不存在,无需删除
    set "success=1"
)

rem 根据操作结果决定退出方式
if !success! equ 1 (
    echo 操作已完成,3秒后自动退出...
    timeout /t 3 >nul
) else (
    pause
)

方式二:

@echo off
chcp 65001
echo Deleting folder...
rd /s /q "D:\测试文件夹"
if %errorlevel% equ 0 (
    echo Folder deleted successfully.
) else (
    echo Failed to delete folder.
)
pause