Thank you! It works!
Now, two more questions:
1. Writing out the entire alpohabet on one line is a bit of a pain because I
have to turn Word Wrap off. Is there any way I can extend the for loop onto
the next line without it interpreting the next as a separate command?
2. Suppose I want to do more with each created directory. Is there a way to
turn the for loop into a block of code that I can then work with each created
directory and then move on to the next one? I was thinking of something like
this:
FOR %%a IN (A B C ... Z) DO:
{
MKDIR %%a if it doesn't exists
COPY all files from c:\temp into c:\temp\%%a that start with that letter
go on to the next letter
}
or something like that
"Pegasus (MVP)" wrote:
>
> "BigDaddyCool" <(E-Mail Removed)> wrote in message
> news:295194F5-ABD5-48F3-85AB-(E-Mail Removed)...
> > Suppose I'm in a directory c:\temp. How do I write a for loop that will
> > create 26 directories, one for each letter of the alphabet? So like after
> > the
> > for loop executes, the directory will have 26 folders like this:
> >
> > c:\temp\a
> > c:\temp\b
> > c:\temp\c
> >
> > ...
> >
> > c:\temp\z
> >
> >
> > Now, I know that to do this from the command-line, you tupe:
> >
> > FOR %a IN (A B C) DO MKDIR %a
> >
> > ...but when I copy and paste the command into a file called CreateDirs.cmd
> > and double click that, it doesn't work. Why does it work at the command
> > line
> > and not in the .cmd file?
>
> .. . . because you must double your % characters when running
> the command from within a batch file.
> @echo off
> for %%a in (A B C) do md %%a
>
>
>
|