如何通过Python或批处理指令删除指定文件夹?

要求输入图片中的路径后执行删除

不清楚你的实际文件/情况,仅以问题中的样例说明及猜测为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的文件放一起双击运行@echo off&cd /d "%~dp0"&mode con lines=5000
rem 根据一个txt文本文件里列出的路径,将指定文件或文件夹删除
set #=Any question&set _=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%_% %z%
set "txtfile=xxx.txt"
if not exist "%txtfile%" (echo;"%txtfile%" not found&pause&exit)
for /f "delims=" %%a in ('type "%txtfile%"') do (
    set "isexist="
    echo;"%%~a"
    if exist "%%~a\" (
        set "isexist=1"&rd /s /q "%%~a\"
    )
    if exist "%%~a" (
        set "isexist=1"&del /a /f /q "%%~a"
    )
    if not defined isexist (echo;not found)
)
echo;%#% +%$%%$%/%_% %z%
pause
exit

温馨提示:答案为网友推荐,仅供参考
相似回答