0

The following lines allowed me to list all the files, folders, and sub-folders in file TXT, but the problem is that the hidden files are not included in file TXT. So, what do I have to do?

@echo off
set /a VAR=%random%  
mkdir C:\Users\Blm\Desktop\folder\
for /r  E:\ %%i in (*) do (echo %%i >> C:\Users\Blm\Desktop\folder\%VAR%.txt)
pause

2 Answers 2

0

Try replacing this line:

for /r  E:\ %%i in (*) do (echo %%i >> C:\Users\Blm\Desktop\folder\%VAR%.txt)

With this one:

dir /s/o/b /a E:\ > C:\Users\Blm\Desktop\folder\%VAR%.txt
0
dir /s /ah /b
  • /s include sub-folders
  • /ah include hidden files (attribute, hidden)
  • /b in bare format (file list only, no columns for size or type)

you don't need to use for loop for simply listing a directory tree

You may use attrib /s /d instead of dir for a similar function but different output displaying file and folder attributes (that's if they're hidden, system, archieve type of files etc) too

Also you might consider using tree /f instead, for a better output formatting, although without showing the hidden files

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .