setlocal enabledelayedexpansion
/* setup the variable enable explansion */
for /f "delims=/" %%i in (c:\Log\SLDPRT.TXT) do (
g:
cd G:%%~pi
set fn=%%~nxi
set pn=%%~pi
set pn=!pn: =+!
/* replace the “blank space” symbol in the pn to “+” */
set pn=!pn:^&=#!
/* the “^” mean is it is itself only*/
echo !fn!
echo !pn!
pause
call :began !pn!
)
goto :eof
/*goto :eof mean is the last command*/
:began
cd ..
set cxs=!pn!
echo !cxs!
set cxs=!cxs:\= !
echo !cxs!
pause
call :nnd %cxs%
goto :eof
:nnd
set tmp1=%2
if defined tmp1 shift && goto nnd
echo "!tmp1!"
pause
set vp=%1
set vp=!vp:+= !
set vp=!vp:#=^&!
/*restore the variable*/
md c:\Log\"!vp!"
copy "!vp!"\"!fn!" c:\Log\"!vp!"
pause
goto :eof
remark:
1.Get directory detial information
dir /b /s g:\ENGINEERING\Department\CHEVASSUS\HINGE_ENDPIECE\* |findstr ".*SLDPRT$" > C:\Log\SLDPRT.TXT
2.this bat program is test only.
3.ohters way can get the result,the following is reference only
for /l %%d in (1,1,256) do if "!pn:~-%%d,1!"=="\" (goto:out) else (set dn=!pn:~-%%d,1!!dn!)
/*the pn is fully qualified path name*/
/*"!pn:~-%%d,1!" mean is display the first symbol of the last %%d */
转载于:https://blog.51cto.com/greenp/903334