Page 1 of 1

How to read folder that contains sub-folders

Posted: 09 Nov 2010 02:08
by newbie
Hello, sorry for interrupting, I just want to ask how to write a batch file that can read and its sub-folders? Recently, I'm working on a batch file for this but it doesn't work, to help more understanding, this is my batch file:
------------------------------------------
@echo off
cls
set counter=0

:loop
set /a counter=%counter%+1

set "mydisk=c:\test\%counter%-7"

echo %mydisk%

if %mydisk% == 7 goto quit

:Quit
----------------------------------------
This is the question, in "c:\test" folder, it contains 7 subfolders (each subfolder contains files), what I want is to display all the files in the subfolders, so how I'm going to do "LOOPING":
- if count == 1, it will display files in folder "1"
- if count == 2, it will display files in folder "2"
until the count == "7", it stops.

*for your information "1" to "7" is a subfolder of "test"

Is is possible to do like this???? my batch works but it does not display files inside the subfolder?????really need HELP?????

Re: How to read folder that contains sub-folders

Posted: 09 Nov 2010 04:11
by amel27

Code: Select all

@echo off
cls

set counter=0

:loop
set /a counter+=1
set "mydisk=c:\test\%counter%"

echo %mydisk%
if %counter% lss 7 goto loop

pause>nul