I'm trying to search my code base for all jscript directories and then get a list of relative files within those directories using the following batch script...
@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!
)
)
It all works as expected until it gets to...
SET "relativePath=!relativePath:%currentDir%=!"
I can figure out what format I need to write this in to turn...
c:\dir\jscript\dev\file.js
into...
file.js
Please help!
Additional information
The directory setup is as follows
dir
jscripts
dev
file.js
file2.js
live
file.js
file2.js
dir2
jscripts
dev
file.js
file2.js
live
file.js
file2.js
I want find all jscripts directories, CD into them, get a list of all JS files relative to the dev directory