15

Somehow like dir /b command but I need also hidden and system files there. Built in dir command doesn't allow to list such 'hidden' files with the rest and I must use /s to have full path in there, which is of course non recursive.

I also played with windows version of ls command and there also no luck. To display full path you must add asterisk (mydir\*) at the end of directory you are listing, but this makes it recursive.

rsk82
  • 1,462

6 Answers6

18

Try the following command:

dir /s /b /a

It will give ALL files, you can run it through FIND if you want or add a folder name.

Renan
  • 8,062
bjkamp
  • 181
11

If you don't want to install anything, you could also use the following command:

for /f "delims=" %a in ('cd') do @for /f %b in ('dir /b /a') do @echo %a\%b

You have to cd into the directory first or it won't work.

Dennis
  • 50,701
1

If you tried ls, why not just install cygwin? You can use find in cygwin:

find -name "*"

If you do install cygwin and want to use find in cygwin, make sure the find in cygwin is called by either using full path or insert cygwin bin path before system32 because Windows also has a find.exe.

Codism
  • 953
0

you could download sed with gnuwin32. This prepends the current directory.

Doing %cd% doesn't work.. so %cd:\=\\% converts every \ to \\, which results in \.

C:\WINDOWS>dir /b | sed "s/^/%cd:\=\\%\\/" 
C:\WINDOWS\0.log
C:\WINDOWS\003109_.tmp
C:\WINDOWS\addins
barlop
  • 25,198
0

This is an old question, but I thought I'd add something anyhow.

DIR doesn't traverse correctly all the directory trees you want, in particular not the ones on C:. It simply gives up in places because of different protections.

ATTRIB works much better, because it finds more. (Why this difference? Why would MS make one utility work one way and another work different in this respect? Damned if I know.) In my experience the most effective way to handle this, although it's a kludge, is to get two listings:

attrib /s /d C:\ >%TEMP%\C-with-directories.txt

attrib /s C:\ >%TEMP%\C-without-directories.txt

and get the difference between them. That difference is the directories on C: (except the ones that are too well hidden). For C:, I'd usually do this running as administrator.

djc
  • 1
0

I wanted to work with a directory listing, so I Googled "Print a Directory". I found instructions to do so, but they included changes to the Registry. Not wanting to diddle with this, and wanting to use a listing, not print it, I found a way to meet my goals without changing the Registry. I created two batch file programs to be saved in a Utility Directory. Then, when I wanted to print or work with a directory, I just copy the appropriate batch file into the subject directory, then execute it! Here they are:

rem PrintThisDirectory.bat
rem Prints the directory where it resides
@echo off
dir %1/-p/o:gn> "%temp%\listing"
start /w notepad "%temp%\listing"

Rem ShowThisDirectory.bat
Rem Displays in Notepad the Directory where it resides
@echo off
dir %1/o:gn> "%temp%\listing"
start /w notepad "%temp%\listing"