Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 396 Vote(s) - 3.39 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loop through files in subdirectories batch file

#1
I am trying to loop through a bunch of files in sub-directories to run a command on them, but I can't seem to figure out how to reach them.

The directory structure is like this:

- Main directory (Holds .bat file and top-level directories)
- Sub-directory
- Search directory
- A bunch of files (I need the locations of all of these separately)

I am able to get a list of all of the files/folders in the "Main directory" using:

for /f %%f in ('dir /b /r *') do echo %%f

but I cannot seem to figure out how to go any further into the directories to get the files in the "Search" directory.

An example of the file structure is:

C:\Users\swiftsly\Search160\0002\search\AP584.txt

Any help is greatly appreciated!
Reply

#2
The final solution to this question, with the help of the recommendation by Squashman to use `/R` instead of `/f` is:

@echo off
for /R %%f in (*.txt) do echo %%f

This will print out a list of all of the .txt files in the sub-directories.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through