DOS batch file

R

Rich

What is the syntax needed to run a series of commands on every subfolder
within a folder? Right now, I have to manually type in the name of each
folder into the batch file and save and execute. It would be nice to set it
up so it automatically hits every subfolder.

Thanks!
 
T

Tim Slattery

Rich said:
What is the syntax needed to run a series of commands on every subfolder
within a folder? Right now, I have to manually type in the name of each
folder into the batch file and save and execute. It would be nice to set it
up so it automatically hits every subfolder.

There's no uniform answer but many commands have a flag that tells
them to recurse through subfolders. Type the command you're interested
in followed by /? on the command line to find out what its flags are:

findstr /?

tells you (among many other things) that specifying /s with the
findstr command causes it to search the current directory and all
subdirectories.
 
P

Pegasus \(MVP\)

Rich said:
What is the syntax needed to run a series of commands on every subfolder
within a folder? Right now, I have to manually type in the name of each
folder into the batch file and save and execute. It would be nice to set
it
up so it automatically hits every subfolder.

Thanks!

Can you give a typical example of the command you wish
to execute in each folder?
 
P

Pegasus \(MVP\)

You could use this batch file:
@echo off
set Target=D:\User Files

for /F "delims=" %%a in ('dir /s /b /ad "%Target%"') do (
echo md "%%a\zips"
)

Remove the word "echo" in the line towards then end in
order to activate the batch file.

By the way, MS-DOS is a legacy operating system that was
introduced some 30 years ago. It is rarely used these days and
it would not understand the above code. This is a batch file
that runs only in a Windows 32-bit environment, usually in
a Command Window.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top