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 need a list of all the files and folders in a folder. My end goal is to print out this list on paper. I don't want this to be recursive, so I don't need a list of the files in folders and the folder being searched. So for example there's folder name foo and it contains the files bar and wombat and a folder called crazy so I need the list to contain

  • bar
  • wombat
  • crazy

I'm using Windows 7.

share|improve this question

marked as duplicate by Karan, AthomSfere, soandos, techie007, Mokubai Jun 23 '13 at 22:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

3 Answers

up vote 7 down vote accepted

Well, from the Windows shell, you can direct the output of dir to a file like this:

dir > list.txt

which will give you the full directory listing. And if you use the /b option, dir will just output the file and directory names, without the additional information:

dir /b > list2.txt
share|improve this answer
    
Thanks, does this get hidden files and folders? –  Celeritas Jun 21 '13 at 20:45
1  
No. You need to use the /a:- option for a listing that includes hidden files and folders. Use dir /? to see a list of options. –  Mox Jun 21 '13 at 20:51
add comment

You could also use Powershell:

Get-ChildItem -Force 

Would get all items, including hidden and protected.

You can the use PowerShell commands to format the text however you wish:

Get-ChildItem -Force | Select-Object Name, Attributes, Extension, LastAccessTime
| Out-File "C:\Results.txt"

Which would look something like:

enter image description here

share|improve this answer
    
+1 POWERSHELL IS KING! –  MDT Guy Jun 21 '13 at 21:43
    
@AthomSfere ls -Fo short form Get-ChildItem -Force ... –  STTR Jun 21 '13 at 22:39
1  
@STTR yes, gci can also be used for Get-ChildItem, ls is the linux equivalent of dir too. I always use longform in scripts though for easy readability for me, new users and posterity. –  AthomSfere Jun 21 '13 at 22:49
    
@AthomSfere It seems to me that a simple, though not the right approach will win). And our perversions with powershell not wanted, that's sad. As a gift analogue paste-d: powershell $f1=gc col1.txt;$f2=gc col2.txt;for($i=0;$i-lt$f1.length;++$i){$f1[$i]+$f2[$i]}>col-new1-2.txt –  STTR Jun 21 '13 at 23:04
add comment

/B - Uses bare format (no heading information or summary)

/A:- - displays files and folders with any attributes

/O:G-N - sort G - Group directories first, -N - reverse By name (alphabetic)

dir /B /A:- /O:G-N

Output:

bar
wombat
crazy

@Mox answer command:

dir /b

Output:

bar
crazy
wombat

@Mox answer command, if wombat set hidden attribute:

dir /b

Output:

bar
crazy

sample at foo folder and save output to C:\mushroom.txt

dir /B 'C:\foo' /A:- /O:G-N>C:\mushroom.txt

powershell alternative:

powershell ls -Fo^|sort Mode,Name -desc^|ft Name -Au -Hi

powershell alternative, file save:

powershell ls -Fo^|sort Mode,Name -desc^|ft Name -Au -Hi|more /E +1>C:\mushroom.txt
share|improve this answer
2  
Please describe how this command works and how to run it. –  gronostaj Jun 21 '13 at 20:22
1  
In general, the mushroom in handy here) youtube.com/watch?v=EllYgcWmcAY –  STTR Jun 21 '13 at 23:22
add comment

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