How to read folder that contains sub-folders

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
newbie
Posts: 24
Joined: 29 Sep 2010 01:30

How to read folder that contains sub-folders

#1 Post by newbie » 09 Nov 2010 02:08

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?????

amel27
Expert
Posts: 177
Joined: 04 Jun 2010 20:05
Location: Russia

Re: How to read folder that contains sub-folders

#2 Post by amel27 » 09 Nov 2010 04:11

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

Post Reply