List files in full path BUT excluding files in subfolders!!!

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jamesfui
Posts: 50
Joined: 27 Mar 2010 23:00

List files in full path BUT excluding files in subfolders!!!

#1 Post by jamesfui » 14 Apr 2010 08:54

hi every dostips batch expert..
need some simple help here on how to list out files in full path to excel BUT excluding files in subfolders!

for example,
c:\document\reports\file01.doc
c:\document\reports\file02.doc
c:\document\reports\submitted\file03.doc
c:\document\reports\submitted\file04.doc

i use the below scripts to list out the wanted *.doc but i don't need the one
in the subfolders.. so what's the mistake with the scripts below!! thanks.

SET location="c:\document\reports"
DIR /S /B %location%\*.doc>> listout.xls

PS. I need the full path of the wanted files so that the listout.xls will be just like below,

listout.xls
----------------content-----------------
c:\document\reports\file01.doc
c:\document\reports\file02.doc

------------------end-------------------

THANKS :D

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: List files in full path BUT excluding files in subfolder

#2 Post by !k » 14 Apr 2010 09:27

Code: Select all

set "location=c:\document\reports"
for %%i in ("%location%\*.doc") do echo %%i>> listout.xls

Post Reply