我看1995年的电脑杂志的“用C语言和批处理文件实现。。。。的一次性转换”时我抄了一下批处理z再改一下注视后才发现这个问题的:
@echo off
if "%1"=="" goto usage
if "%1"=="/?" goto usage
if "%2"=="#has_drv" goto chg_drv
for %%c in (/%1) do set $=%%c
for %%c in (/%$%) do if "%%c"==":" goto has_colon
goto chg_drv
:has_colon
for %%c in (/%1) do %0 %1 #has_drv %%c:
:usage
echo Change Drive and Directory.
echo Made By DEFRAG 2004.12.09 China DOS Union
echo.
echo Usage:CDD Path
echo.
goto exit
:chg_drv
set $=
%3
if not "%1"=="%3" cd %1
:exit