-1

最小のディレクトリを識別し、最小のディレクトリのみを残して他のすべてのディレクトリを削除するバッチファイルがあります。

識別は適切に機能しますが、他の大きなフォルダーの削除は機能しません。以下は私が今持っているものです。何を変更する必要がありますか?

@echo off
setlocal EnableDelayedExpansion

rem Get size of all folders
set smallestSize=9999999999
for /D %%a in (*) do (
   set size=0
   for %%b in (%%a\*.*) do set /A size+=%%~Zb
   if !size! lss !smallestSize! (
      set smallestSize=!size!
      set smallestName=%%a
   )
)

echo Deleted folder: "%smallestName%"
pause

rem Delete all folders, except the smallest one.
for /D %%a in (*) do (
   if "%%a" neq "%smallestName%" rmdir /S /Q "%%a"
4

1 に答える 1

0

単純なタイプミスの可能性があります - 最後の閉じ括弧がありませんfor/do

于 2014-11-02T04:25:09.857 に答える