| 
 | 
 
[这个贴子最后由gotomsdos在 2005/04/20 12:41pm 第 3 次编辑] 
 
这段时间,做综合游戏启动光盘,想实现创建新的多层带间隔的长名目录,需要命令行自动的.,但是又找不到适合的程序,所以就用WBAT和GET,FIND写的创建带间隔的长名目录小批处理: 供参考, 
在纯DOS运行成功..,在XP DOS窗口可能不行......(经测试,可以建105个字符(包括"\")的带间隔多层目录, 但\前后不能有间隔,WBAT BOX 可以显示120之内的字符,包括按钮) 
要求:加载了DOSLFN 
echo off 
cls 
goto begin 
:lfn "to create long name folder with spaces !"   [x] 
please input  folder name to creat: 
[$ lfn 105                                          ] 
                        [show it first] [just create] 
: 
:begin 
call w.bat box @%0:lfn 
if  errorlevel 100 goto final 
if not "%lfn%"=="" goto  go 
wbat box "no input yet ! input ?" input,exit 
if errorlevel 2 goto final 
goto begin 
:go 
if  errorlevel 2 goto create 
wbat box "%lfn%" continue... 
:create 
get z "%lfn%" 1 
dir "%lfn%" /w/ad|find "%get%" 
if not errorlevel 1 goto final 
md "%lfn%" 
get z "%lfn%" 1 
dir "%lfn%" /w/ad|find "%get%" 
if not errorlevel 1 goto final 
:start 
set pos= 
set left=%lfn% 
set right= 
:toleft 
wbat box "to search existing directory by allocating ';\';" continue... 
get # "%left%" ';\'; /x 
set pos=%get% 
get z "%lfn%" %pos% 
set right=%get% 
get r "-" %pos% /w1 
get z "%left%" /w%get% 
set left=%get% 
wbat box "checking^%left%" continue... 
get z "%left%" 1 
dir "%left%" /w/ad|find "%get%" 
if not errorlevel 1 goto exist 
wbat box "%left%^doesn';t exist!" continue... 
goto  toleft 
:exist 
wbat box "%left%^exists!" continue... 
goto make 
:toright 
wbat box "succeeded!" continue... 
:make 
wbat box "now about to create new directory to right!" continue... 
if "%right%"=="" goto  end 
get # "%right%" ';\'; 
if "%get%"=="0" goto last 
get r "+" %pos% /w%get% 
set pos=%get% 
get r "-" %pos% /w1 
get z "%lfn%" /w%get% 
set left=%get% 
get z "%lfn%" %pos% 
set right=%get% 
wbat box "creating^%left%" continue... 
md "%left%" 
wbat box "checking if succeeded" continue... 
get z "%left%" 1 
dir "%left%" /w/ad|find "%get%" 
if not errorlevel 1 goto toright 
goto fail 
:last 
md "%lfn%" 
:end 
get z "%lfn%" 1 
dir "%lfn%" /w/ad|find "%get%" 
if not errorlevel 1 goto ok 
:fail 
wbat box "FAIL creating new directory !!" retry,back 
if errorlevel 2 goto  final 
goto start 
:ok 
wbat box  "SUCCEEDED creating ENTIRE directory !!" finish 
:final 
 |   
 
 
 
 |