@echo off
rem echo 清空文件夹打包脚本 V1.0.0.20210106
pushd %~dp0
setlocal enabledelayedexpansion
set sDstDirPath=%1
SET sDstDirPath="%sDstDirPath%"
SET sDstDirPath=%sDstDirPath:"=%
rem echo sDstDirPath=%sDstDirPath%
if "%sDstDirPath%"=="" (
echo 待清空文件夹路径为空
echo 调用格式:ClearDir.bat 待清空文件夹路径
exit /b 1
)
del /S /Q "%sDstDirPath%" >nul || goto :error
cd /d "%sDstDirPath%"
for /f "delims=" %%i in ('dir /B /A:D') do (
rd /S /Q %%i >nul || goto :error
)
goto :success
:error
endlocal
popd
echo 清空文件夹%sDstDirPath%发生错误,错误码为%errorlevel%.
exit /b %errorlevel%
:success
echo 成功清空文件夹%sDstDirPath%
endlocal
popd
exit /b 0