1.

Solve : Help me with a batch that goes recursevly through folder structure?

Answer»

Hello,

can anyone of you give me a hint on a bat file that would go through a folder structure and read data from a specific file ( .txt)

so the ideea is that this .txt file exists in all folders, I need a bat that would read step by step all txt file from al folders

00_Documentation
         test.txt
01_File
         test.txt
        01_subfolder
                     test.txtI don't mean to pry (actually I guess I kind of do), but what exactly are using the read text for? Why does it need to hit all folders and what exactly is it going to do?Good QUESTION...In each folder I have a file a Text file which contains all files name from the folder, I need to read all those files and take out the files names.
I hope I made my self understood:

e.g
00_Documentation
     file1.ppt
    file.2.doc
    file3.xls
    test.txt

in the test file is written that in in 00_Documentation I have the 3 files, I want an automatic way to tell me which files are in which foldersI know this may seem simple, but why wouldn't this work?

Code: [Select] dir c:\ /s /b
That will LIST your ENTIRE directory structure by file name.

Either that, or if you are needing from the test.txt file try this:

Code: [Select]for /f "delims=" %%A in ('dir /s /b *test.txt ') do (
  type %%A
  pause
)

That will go through and display the contents of all of the test.txt files that it can find, pausing for you after each one. If you are looking to output this to a file just use type %%A>c:\file.txt in place of the second line. If you are needing this to do more, like read into each file looking for something, an EMBEDDED for loop would probably be your better option. But again, it is a little difficult to know what it is you are looking to accomplish, especially when the first command should be enough to eliminate the need for your test.txt files.



Discussion

No Comment Found