Re: For Command - can I do IN clause: ('cmd 1 & cmd 2') ???



The three-line batch file below will list all files in each
of the subdirectories that hang off the current directory.
It will then list every file stored in the current directory.

@echo off
for /d %%d in (*.*) do for /F "tokens=*" %%* in ('dir "%%d" /B /a-d /S
/O:N') do echo %%*
for /F "tokens=*" %%* in ('dir /B /a-d /O:N') do echo %cd%\%%*

"dino" <dino@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1C49D996-0D62-44F8-AC68-0CA6383B5CC9@xxxxxxxxxxxxxxxx
Thanks again for your perseverance.

I need to parse each line of a list of files. The list must be presented
in
the order I originally described as they partially, functionaly "overlap"
one
another and my precedane requirements will be then met.

As I said the list must be in this order:

I am trying to get a listing of all files in the directory structure at
and
below the <current directory> - BUT I need to see the files in the
<current
directory> LAST i.e. after all of the sub directories and their
descendants.
I need this because when filenames appear more than once, the <current
directory takes precedence) otherwise they are to be considered in alpha
order.


"Pegasus (MVP)" wrote:

I'm sure there is a way to do what you want to do.
So far you have presented your partial solutions,
which you say do not work properly. Instead you
should start with a description of your ***functional
requirements***:

In other words: What exactly do you expect your
command to do?


"dino" <dino@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:78002FAE-CF94-44DC-9192-B493CF18DF35@xxxxxxxxxxxxxxxx
Thanks for your help Pegasus but while your answer works, (although I
do
not
think you need the first dir /AD and you meant /A:D not /A:-D on
the
last
dir) it still is two commands as I had at first and does not let me
pass
two
commands to an outer wrapping for command.

I need to parse the files in the generated list.
SO is there a syntax whereby I can do: ('dir . /A:D /B /S /O:N & cd
')
or your simpler
('for /d %%a in (*.*) do dir "%%a" /B /S /O:N & dir /A:-D /B /S /O:N
')

As a commnd IN lcause to an outer for statement?



for /F %Q in ('( dir . /A:D /B /S /O:N & cd )')
do (for /F %R in ('dir %Q\*.* /A:-D /B')
do echo %~fxR )




"Pegasus (MVP)" wrote:


"dino" <dino@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BAD9E0E2-009A-40D2-B360-7E7B7C648F4E@xxxxxxxxxxxxxxxx
I am sorry maybe I was unclear:

I need to see all the files in the subdirectories BEFORE I see the
files
in
the <CURRENT DIRECTORY>

SO if I am at the root and i have files/directories as follows

\dog.txt
\cat.txt
\mouse.txt
\bird.txt
\fourLeggedAnimals\dog.txt
\fourLeggedAnimals\cat.txt
\fourLeggedAnimals\mouse.txt
\pets\dog.txt
\pets\cat.txt
\pets\mouse.txt
\pets\bird.txt
\twoLeggedAnimals\bird.txt


I need to process the files in this order:

\fourLeggedAnimals\dog.txt
\fourLeggedAnimals\cat.txt
\fourLeggedAnimals\mouse.txt
\pets\dog.txt
\pets\cat.txt
\pets\mouse.txt
\pets\bird.txt
\twoLeggedAnimals\bird.txt
\dog.txt
\cat.txt
\mouse.txt
\bird.txt


That is why I want to do

dir . /A:D /B /S /O:N to first get me the list of subdirectories
then cd to get me the name of the <current directory>
yielding:

\fourLeggedAnimals\
\pets\
\twoLeggedAnimals\
\


Then I can do a dir on each of these directories

dir \fourLeggedAnimals\
dir \pets\
dir \twoLeggedAnimals\
dir \

yielding me the highest level directory last

This is just as simple:

@echo off
dir /AD
for /d %%a in (*.*) do dir "%%a" /B /S /O:N
dir /A:-D /B /S /O:N








.



Relevant Pages

  • Re: Looping through Directories...
    ... then change the echo lines to ... replacing Newdir1 & Newdir2 with the directory names you want to use. ... > subdirectories are created in each of the apple types. ... > I know I want to sort of combine a DIR command with a FOR LOOP ...
    (microsoft.public.win2000.cmdprompt.admin)
  • /usr/local removed... but entries for it exist yet!
    ... I do not want to open another wrong PR about NetBSD. ... echo x - ./dot.cshrc.patch ... X # directory with all of the subdirectories listed for the keyword _subdir. ... Xecho x - ./dot.cshrc.patch ...
    (comp.unix.bsd.netbsd.misc)
  • Re: A handy utility (at least for me)
    ... an arbitrary numebr of subdirectories). ... If echo is a shell built in, then it works just fine, and the xargs ...
    (freebsd-hackers)
  • Re: For Command - can I do IN clause: (cmd 1 & cmd 2) ???
    ... "Pegasus (MVP)" wrote: ... I need to parse the files in the generated list. ... do echo %~fxR) ... yielding me the highest level directory last ...
    (microsoft.public.windowsxp.general)
  • filtype() Problems
    ... I wrote a simple script utilizing readdirto read the contents of a directory, then of all subdirectories and thier contents and echo the filenames to the page. ...
    (comp.lang.php)