我正在尝试在我的代码库中搜索所有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文件的列表
@echo off
setlocal enableextensions enabledelayedexpansion
rem Where to start
pushd "c:\wherever\global2_root\"
rem Search .....\dev directories
for /f "tokens=*" %%d in ('dir /ad /s /b ^| findstr /e "\\dev"') do (
rem change to that directory
pushd "%%~fd"
echo Now in !cd!
rem process files inside directory
for %%f in (*.js) do (
echo %%f
)
rem return to previous directory
popd
)
rem return to initial directory
popd
rem cleanup
endlocal
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句