Board logo

标题: 怎样在TXT文件的路径名里去掉文件名 [打印本页]

作者: terse     时间: 2006-12-6 01:46    标题: 怎样在TXT文件的路径名里去掉文件名

dir %gpath%*.gho /b /s >>%temp%\tmp.txt
call w.bat list @%temp%\tmp.txt:w_dir
if errorlevel 100 goto rec
if "%wbat%"=="" goto rec
set gfile=%wbat%

以上运行得到:
C:\2000.GHO
C:\GHOST\2000.GHO
C:\GHOST\2000E.GHO

能否的到:
C:\
C:\GHOST
C:\GHOST
作者: vkill     时间: 2006-12-6 01:59
%%~dpi
作者: lxmxn     时间: 2006-12-6 02:05

@echo off
for /f "delims=" %%i in (' dir %gpath%*.gho /b /s ') do echo %%~dpi>>%temp%\tmp.txt

作者: terse     时间: 2006-12-6 05:03
先谢两位
在dos下用 for /f "delims=" %%i in (' dir %gpath%*.gho /b /s ') do echo %%~dpi>>%temp%\tmp.txt
替代 dir %gpath%*.gho /b /s >>%temp%\tmp.txt  出错!
什么原因呢?