Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to find a way to get a listing of all files, without hidden directories. I have tried several variations of something like this:

dir  /b  /s  /a:-h  z:\  >toc-z.txt

but this only skips over hidden files. I need a listing which excludes all hidden folders, including files and sub-folders of these hidden folders.

Is there any way I can skip parsing and listing of hidden folders?

share|improve this question
    
Not with a simple dir command, since it will still display files and folders which are inside the hidden folders but aren't hidden themselves. It might be simpler to do this using PowerShell instead of batch, or use a better shell such as Take Command, whose dir command supports extended options such as "/Nd: Skip hidden directories (when used with /S)". –  Karan Jan 9 '13 at 0:56

2 Answers 2

It's a bit hackish, but you could probably use the xcopy command with the /l and /s (or perhaps the /e) options. The key is the /l option which tells it to display a list of files that are to be copied rather than making any copies. By default, xcopy does not copy hidden or system files so they will be ignored.

share|improve this answer

It's a long command, but it works, and it is fairly fast :-)

Here it is as a long one liner for the command line

>toc-z.txt ((for %F in ("z:\*") do @echo %F)&for /f "delims=" %D in ('dir /s /ad-h-l /b z:\*^|sort') do @for %F in ("%D\*") do @echo %F)

Here it is as a batch file

@echo off
>toc-z.txt (
  for %%F in ("z:\*") do @echo %%F
  for /f "delims=" %%D in (
    'dir /s /ad-h-l /b z:\*^|sort'
  ) do for %%F in ("%%D\*") do echo %%F
)
share|improve this answer
    
EDIT - major fixes: 1) added log, 2) added root files, 3) made root z:\ 4) eliminate reparse points, 5) sort output to be depth first –  dbenham Jan 9 '13 at 16:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.