Page 1 of 1

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

Posted: 14 Apr 2010 08:54
by jamesfui
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

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

Posted: 14 Apr 2010 09:27
by !k

Code: Select all

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