DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: SOLVED: directory tree 'crawler'  (Read 7,245 times)

Pattern-chaser

  • Participant
  • Joined in 2011
  • *
  • Posts: 4
SOLVED: directory tree 'crawler'
« on: March 07, 2011, 11:41 AM »
My request is for a utility that will execute a given command in the starting directory, and also in all sub-directories in that directory. A very simple example of usage:

Crawler "C:\Code" "Dir *.c"

Will list all C source code files in C:\Code, and in all sub-directories. This example isn't even necessary, as "Dir" will do it for you, but you can see how useful it could be when you use a more meaningful command.

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge

Pattern-chaser

  • Participant
  • Joined in 2011
  • *
  • Posts: 4
Re: IDEA: directory tree 'crawler'
« Reply #2 on: March 07, 2011, 01:53 PM »
Even better than having it written for me: a pointer to where someone already did it! Thanks Skwire!

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: IDEA: directory tree 'crawler'
« Reply #3 on: March 07, 2011, 01:56 PM »
You're welcome.  :)

capitalH

  • Participant
  • Joined in 2008
  • *
  • Posts: 71
Re: SOLVED: directory tree 'crawler'
« Reply #4 on: March 08, 2011, 09:29 AM »
or save a batch file with the following content

Quote
c:
cd C:\Code
for /f "tokens=*" %%d in ('dir /ad/b/s') do dir "%%d\*.c"
The first two lines is just to ensure you are in the right subdirectory
replace
dir "%%d\*.c"
with the command of your choosing (keeping the %%d though - which is each directory - try running with echo dir "%%d\*.c" to see what the actual command will be that will be run - without doing something weird to your system!)

No download, portable (windows only though) small filesize and no malware.

Original address: https://www.donationcoder.com/forum/index.php?topic=25982.0