File listing command under windows

I got this simple request from someone I know. He wants to list all the files in a specific folder, copy them to a text file, so he can send these to someone else for processing.

Well, this is very easy. We just use the dir command for that, and then we redirect it to a file. For example, lets list all the jpeg files:

dir *.jpg > my_pictures.txt

However, We might have pictures in many formats. So, we would like to include these as well:

dir *.jpg *.png *.jpeg > my_pic.txt

That will do the trick. Note, however, that some header information is still included. We only want the file names, nothing else. So, we use the /b (bare – no headers) switch to achieve this goal:

dir /b *.jpg *.png *.jpeg > my_pic.txt

Now this is a serious progress. But… Lets say that our files are not listed in a single directory. Lets say we have some sub directories that we like to search as well. No problem! we will add the /s (sub directory) switch:

dir /b/s *.jpg *.png *.jpeg > my_pic.txt

That’s All! we can now list any Items in this folder and any folder inside it into a text file. if that is a big file, I suggest compressing it.

Leave a Reply

You must be logged in to post a comment.


Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/61/4091161/html/wptalreg/wp-content/plugins/vsf-simple-stats/vsf_simple_stats_shutdown.php on line 17

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/content/61/4091161/html/wptalreg/wp-content/plugins/vsf-simple-stats/vsf_simple_stats_shutdown.php on line 17

Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in /home/content/61/4091161/html/wptalreg/wp-content/plugins/vsf-simple-stats/vsf_simple_stats_shutdown.php on line 17

Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/61/4091161/html/wptalreg/wp-content/plugins/vsf-simple-stats/vsf_simple_stats_shutdown.php on line 45

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/content/61/4091161/html/wptalreg/wp-content/plugins/vsf-simple-stats/vsf_simple_stats_shutdown.php on line 45

Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/61/4091161/html/wptalreg/wp-content/plugins/vsf-simple-stats/vsf_simple_stats_shutdown.php on line 47

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/content/61/4091161/html/wptalreg/wp-content/plugins/vsf-simple-stats/vsf_simple_stats_shutdown.php on line 47

Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in /home/content/61/4091161/html/wptalreg/wp-content/plugins/vsf-simple-stats/vsf_simple_stats_shutdown.php on line 47