views:

246

answers:

1

Hello I need a batch file to store in a variable all paths of all directories/subdierectories named ".svn" that I can found in my_folder.

Something like:

@ECHO OFF
FOR /r my_folder %%X IN (.svn) DO (ECHO %%X)

the command above prints them to screen, but I need to store them in a variable as a list of strings. Someone knows how to do it?

This is the site I use for helping myself with batch files: http://ss64.com/nt/

After I want to pass the value of such varibale to the command RD in order to delete them along with theis subfolders/files. So let's say the varibale is names $a i will do something like:

RD /s /q $a
+1  A: 

The simplest solution without any variables is to issue the RD command inside your FOR loop. You can use multiple commands inside the braces like:

@ECHO OFF
FOR /r my_folder %%X IN (.svn) DO (
    ECHO %%X
    RD /s /q %%X
)

If yo need the to add the pathes to a variable you can do it like that:

@ECHO OFF

SET PATH_LIST=
SETLOCAL ENABLEDELAYEDEXPANSION   

FOR /r my_folder %%X IN (.svn) DO (
    ECHO %%X
    SET PATH_LIST=!PATH_LIST! "%%X"
)

ENDLOCAL

RD /s /q %PATH_LIST%

But keep in mind that environment variables are limited in size. In Windows XP a single variable can hold a max. of 8,192 bytes.

Frank Bollack