Answer the question
In order to leave comments, you need to log in
How to output part of the path correctly?
You need to sort through all the folders. If there is a test.js file in the folder. You need to take the part of the path after the initial one and use it further. And the problem is that it is not possible to display this path.
If it does, then this is the path used in the last step of the loop.
Nesting can be any, but it seems that the condition normally works, only the output of this path remains. How to implement it?
for /r "G:\test\batch" /d %%i in (*) do (
Set namePath=%%i
IF EXIST %%i\test.js (
Set "namePath=%namePath:G:\test\batch=%"
Set "namePath=%namePath:\=/%"
echo "namePath : %namePath%"
)
)
Answer the question
In order to leave comments, you need to log in
In general, you are doing everything right, except for a few nuances.
Here is an example:
@echo off
SetLocal EnableDelayedExpansion
set "begindir=G:\test\batch"
for /r "%begindir%" %%i in (*) do (
Set "namePath=%%i"
set "namePath=!namePath:%begindir%=!"
echo.!namePath!
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question