Saturday 11 June 2011

How to create the list of files & folders of a directory in windows and save it in text(.txt) format

I was faced with this problem during my M.Tech. thesis. I had to create a list of files & folders of a directory and save it in text(.txt) format in some other location. This I had to do on a windows machine. The method described below will work on Windows XP, Windows Vista & Windows 7. 

The problem was something like this. There is a folder A. I had to create the list of files & folders of directory A and save it in text file in some other location. 

I searched on various websites, and finally I solved the problem in the following way.

Lets suppose, A = "C:\Documents and Settings\". You want to create the list of files & folders of directory A to a defined location B, where lets suppose that B = "F:\". Then the following steps should be followed:

  • Go to run
  • Type  cmd and enter
  • Type  dir "C:\Documents and Settings\">"F:\dirlist.txt" and enter

where, dirlist.txt is the file which contains the list of files and folders of  directory A="C:\Documents and Settings\". You can change the location B as per your convenience. The method described above will work for any choice of A and B.

Sometimes it might not work because of the problems with copy pasting of inverted comma's. So make sure that you re-enter the inverted comma's on command promt before entering.

For any query, you can comment on the post.

Labels: ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home