Re: Looping through Directories...

From: Paul R. Sadowski (xpert_at_mailshell13.mailshell.com)
Date: 05/14/04


Date: Thu, 13 May 2004 23:45:07 -0400

Test it, then change the echo lines to
  md "%%c\Newdir1"
  md "%%c\Newdir2"
replacing Newdir1 & Newdir2 with the directory names you want to use.

@echo off
for /f "tokens=*" %%c in ('dir /s/b/a:d %~dp0') do (
  echo %%c\Newdir1
  echo %%c\Newdir2
)

"Holden Caulfield" <commanderblop@hotmail.com> wrote in message
news:6d0ce83a.0405131914.79dc5fda@posting.google.com...
> Hi there!
> I need a working batch file that:
>
> 1.Takes the current directory it is run from and loops through each
> exisiting folder
> 2.in doing so creates 2 new subdirectories in each existing directory
>
> So, if I run the batch file in c:/apples, which has these
> subdirectories, grannysmith, macinstosh and golden_delish, 2
> subdirectories are created in each of the apple types.
>
> That's It!
> (But just in case you want more info, here it is...)
>
> Background: I am using a PNG to JPG converter to literally convert
> thousands of PNGs to JPGs in thousands of different directories, and
> need to automate the process. The images are converted and saved into
> 2 subdirectories because they are resized to two different sizes as
> well.
>
> I know I want to sort of combine a DIR command with a FOR LOOP
> command, and then create the subdirs (and run my command line
> converter), but I don't know how toprogram batch files that well, and
> I need to get this thing done ASAP. I searched for the last two hours
> on a resource that does this (I think) simple requirement, but to no
> avail.
>
> I appreciate any and all help. Especially a working batch file! ;)
>
> Thanks,
> Holden



Relevant Pages

  • Re: How to find total MB of a directory plus all subdirectories
    ... Nigel Henry wrote: ... named Sounds Library, this contains many subdirectories, which contain ... What command can I use to find out the disk space this directory is ... subdirectories are multi worded without any hyphens, ...
    (Fedora)
  • Re: Need some small help on shell script - delete old files
    ... command so that it does not search subdirectories past this directory ... Please look at my original script from the first message to this ... # this is sufficiently unique in the BKPPATH ... The find command shows all files in the directory and subdirectories. ...
    (comp.unix.shell)
  • Re: Need some small help on shell script - delete old files
    ... command so that it does not search subdirectories past this directory ... The find command shows all files in the directory and subdirectories. ... gzip of $FILENAME at the end is not necessary as far as I can tell ... I am running the script and have noticed that the file names have been ...
    (comp.unix.shell)
  • Re: How to delete directory someone created in my directory
    ... I also cannot change the protections of the directory. ... This command has been superseded by the SET SECURITY/PROTECTION ... This may generate errors if it tries to delete non-empty subdirectories. ... See Help Backup /BY_OWNER to learn about setting the owner of ...
    (comp.os.vms)
  • Re: Need some small help on shell script - delete old files
    ... command so that it does not search subdirectories past this directory ... The find command shows all files in the directory and subdirectories. ... I am using your script. ... recent dump is always left un-compressed with no .gz extension. ...
    (comp.unix.shell)