Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 206 Vote(s) - 3.36 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Batch file to list all files in a dir in windows 7

#1
I'm trying to list all the files in a directory and then write that to a text file using a batch file. I think it should be something like

dir / (some flags here) >> files.txt

which will contain a listing like

a.exe
b.exe
c.exe

etc. etc
Reply

#2
Here you go

dir C:\ /s /b >files.txt
Reply

#3
You pretty much have it down already.
if you are only wanting to list the files in that directory then

dir /A-D >> somefile.txt

OR

dir /A-D > somefile.txt

dir /

- `>>` appends
- `>` creates new or overwrites existing

dir /A-D /ON > somefile.txt

This will sort by name.
Reply

#4
you can also use tree for recursive list files in directory tree

and for dumping to text file you can use this:

> C:\tree "D:\my directory" > "D:\dump file.txt"
Reply

#5
You have to use the `/b` switch (to write file list only, without header and other informations).

dir /b >> list.txt

Then if you need to list all `.exe` files in `c:\windows` the full command is:

dir c:\windows\*.exe /b >> list.txt

Please note that `>>` will **append** the list to the file. Do not forget you can use multiple search patterns, for example:

dir *.jpg;*.png /b > list.txt

It'll write all the `.jpg` and `.png` files (only names, without path or any other informations) to the file `list.txt` (overwriting the file if it did exist before).

If you need to exclude directories you can rely on `/a` switch (to include/exclude items according to an attribute). In your case you want to exclude directories then you have to use `-d`:

dir /b /a-d >> list.txt

Finally do not forget `dir` can be used recursively with `/s` switch (to list files that match search pattern in the given directory and in all sub-directories) and sorted with `/o` option. Use `dir /?` for more details about that.


Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through