DOS批处理命令中FOR /R命令的问题
批处理文件中用for/RD:\站点\SPDataQuality%%Gin(.)do@echo%%G得到一组目录路径,如下D:\站点\SPDataQuality\.D:\站...
批处理文件中用for /R D:\站点\SPDataQuality %%G in (.) do @echo %%G得到一组目录路径,如下
D:\站点\SPDataQuality\.
D:\站点\SPDataQuality\.kde\.
D:\站点\SPDataQuality\.kde\Autostart\.
D:\站点\SPDataQuality\jpgraph\.
D:\站点\SPDataQuality\jpgraph\docs\.
D:\站点\SPDataQuality\jpgraph\docs\chunkhtml\.
D:\站点\SPDataQuality\jpgraph\docs\chunkhtml\example_src\.
D:\站点\SPDataQuality\jpgraph\docs\chunkhtml\images\.
D:\站点\SPDataQuality\jpgraph\docs\classref\.
D:\站点\SPDataQuality\jpgraph\src\.
D:\站点\SPDataQuality\jpgraph\src\barcode\.
D:\站点\SPDataQuality\jpgraph\src\barcode\demoapp\.
D:\站点\SPDataQuality\jpgraph\src\barcode\examples\.
D:\站点\SPDataQuality\jpgraph\src\Examples\.
D:\站点\SPDataQuality\jpgraph\src\fonts\.
D:\站点\SPDataQuality\jpgraph\src\lang\.
D:\站点\SPDataQuality\jpgraph\src\themes\.
D:\站点\SPDataQuality\others\.
这些路径都是绝对路径,通过什么办法可以把这些都变成相对路径了,也就是说把"D:\站点\"变成".\"列出来? 展开
D:\站点\SPDataQuality\.
D:\站点\SPDataQuality\.kde\.
D:\站点\SPDataQuality\.kde\Autostart\.
D:\站点\SPDataQuality\jpgraph\.
D:\站点\SPDataQuality\jpgraph\docs\.
D:\站点\SPDataQuality\jpgraph\docs\chunkhtml\.
D:\站点\SPDataQuality\jpgraph\docs\chunkhtml\example_src\.
D:\站点\SPDataQuality\jpgraph\docs\chunkhtml\images\.
D:\站点\SPDataQuality\jpgraph\docs\classref\.
D:\站点\SPDataQuality\jpgraph\src\.
D:\站点\SPDataQuality\jpgraph\src\barcode\.
D:\站点\SPDataQuality\jpgraph\src\barcode\demoapp\.
D:\站点\SPDataQuality\jpgraph\src\barcode\examples\.
D:\站点\SPDataQuality\jpgraph\src\Examples\.
D:\站点\SPDataQuality\jpgraph\src\fonts\.
D:\站点\SPDataQuality\jpgraph\src\lang\.
D:\站点\SPDataQuality\jpgraph\src\themes\.
D:\站点\SPDataQuality\others\.
这些路径都是绝对路径,通过什么办法可以把这些都变成相对路径了,也就是说把"D:\站点\"变成".\"列出来? 展开
2个回答
展开全部
@echo off
setlocal enabledelayedexpansion
set p=D:\站点\SPDataQuality
for /R %p% %%G in (.) do (
set x=%%G
set x=!x:%p%=.!
echo !x!)
pause
setlocal enabledelayedexpansion
set p=D:\站点\SPDataQuality
for /R %p% %%G in (.) do (
set x=%%G
set x=!x:%p%=.!
echo !x!)
pause
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询