【问题标题】:Batch File Deleting Contents But Leaving Folder批处理文件删除内容但离开文件夹
【发布时间】:2018-03-03 00:51:20
【问题描述】:

我正在运行一个批处理文件,以根据 deletedirs.txt 中存在的子文件夹名称删除临时目录的内容(和子文件夹)

FOR /F %%i IN (C:\deletedirs.txt) DO del "C:\temppurge\*" rmdir /s /q "C:\temppurge\"%%i

删除 temppurge 目录中子文件夹的内容,但保留子文件夹本身。我错过了什么?

【问题讨论】:

标签: batch-file


【解决方案1】:

使用这个批处理文件(shell 脚本)。

@echo off
setlocal enableextensions
if {%1}=={} goto :HELP
if {%1}=={/?} goto :HELP
goto :START

:HELP
echo Usage: %~n0 directory-name
echo.
echo Empties the contents of the specified directory,
echo WITHOUT CONFIRMATION. USE EXTREME CAUTION!
goto :DONE

:START
pushd %1 || goto :DONE
rd /q /s . 2> NUL
popd

:DONE
endlocal

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-11
    • 1970-01-01
    • 1970-01-01
    • 2018-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多