glmxndr
glmxndr

Reputation: 46616

Batch : list all the subfiles with their absolute path

I want to generate a classpath automatically with all the *.jar files contained under my lib folder.

I can't find a way to list all these files with their absolute path, so that I can build my classpath variable.

It seems the dir command do not allow to get the absolute path, even when you go recursively with a /s.

Basically what I had in mind was something like :

set classpath = ./conf
for %%i in (`dir /s /withaboslutepath *.jar`) do set classpath = %classpath%;"%%x"

Is there a way to achieve this ?

Upvotes: 0

Views: 711

Answers (1)

chalup
chalup

Reputation: 8516

I've created something like this:

setlocal EnableDelayedExpansion
set classpath=./conf
FOR /R . %%x IN (*.jar) do set classpath=!classpath!;"%%~px"
echo !classpath!
endlocal

The problem with this solution are the duplicated paths.

Upvotes: 1

Related Questions