【发布时间】:2013-11-20 06:23:05
【问题描述】:
我正在尝试在我的代码库中搜索所有 jscript 目录,然后使用以下批处理脚本获取这些目录中的相关文件列表...
@echo off
setlocal enableextensions enabledelayedexpansion
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S jscripts') DO (
CD %%G
CD dev
SET "currentDir=!cd!"
IF NOT "!currentDir:~-1!"=="\" SET "currentDir=!currentDir!\"
FOR /r %%F IN (*.js) DO (
SET "relativePath=%%F"
SET "relativePath=!relativePath:%currentDir%=!"
ECHO !relativePath!
)
)
一切都按预期进行,直到...
SET "relativePath=!relativePath:%currentDir%=!"
我可以弄清楚我需要用什么格式来写这个……
c:\dir\jscript\dev\file.js
进入...
file.js
请帮忙!
其他信息
目录设置如下
dir
jscripts
dev
file.js
file2.js
live
file.js
file2.js
dir2
jscripts
dev
file.js
file2.js
live
file.js
file2.js
我想找到所有 jscripts 目录,将 CD 放入其中,获取 相对于 dev 目录的所有 JS 文件的列表
【问题讨论】:
标签: windows batch-file