如
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
if not exist %%a:\nul ‘这行后加跳出命令
if exist %%a:\nul (
for /f "tokens=3" %%b in ('dir /-c %%a:\^|find "可用字节"') do set freesize=%%b
set /a freesize=!freesize:~0,-3!/1049>nul
echo %%a 盘剩余空间:!freesize! MB
)
)
pause
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
if not exist %%a:\nul goto :eof
for /f "tokens=3" %%b in ('dir /-c %%a:\^|findstr "可用字节"') do set freesize=%%b
set /a freesize=!freesize:~0,-3!/1049>nul
echo %%a 盘剩余空间:!freesize! MB
)2>nul
pause
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
FOR %%A IN (C D E F G H I J K L M N O P Q R S T U V W) DO (
VOL %%A: >NUL 2>NUL
IF NOT ERRORLEVEL 1 (
FOR /F "TOKENS=3" %%B IN ('DIR /-C %%A:\^|FIND "可用字节"') DO SET FREESIZE=%%B
SET /A FREESIZE=!FREESIZE:~0,-3!/1049>NUL
ECHO %%A 盘剩余空间:!FREESIZE! MB
) ELSE (
GOTO END
)
)
:END
PAUSE
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
if not exist %%a:\nul goto :eof
for /f "tokens=3" %%b in ('dir /-c %% ...
if not exist %%a:\nul
问题1 用这个命令可以判断空盘符?能否给讲下原理?
2 \nul是什么意思?
问题已经搞清楚了,不用回答了,感谢ccwan的范例,让我学到很多!
[ Last edited by logictianjin on 2007-4-10 at 11:28 AM ]