Friday, 31 July 2020

How to store directory listing - file names in a file.

How to store files names in a directory???

How to keep multiple directory file names backup everyday?

 Syntax 
       >   >>
  
dir



Description:-

Output redirection command. Stores list of file-name of subdirectories and directory. 

>    Create New file name every time and write output text.

>> Append output to Given filename. Write text to filename  one by one.

Examples:-  

Type following command in Dos Prompt without batch file.

dir c:\bat\*.txt        or    c:\bat\dir *.txt

or

  1. c:\main\dir *.* > c:\main\dirlist1.txt   All listing of files stored in dirlist11.txt, instead of displayig in computer screen. 
  2. c:\main\dir *.exe > c:\main\dirlist2.txt  All *.exe file name stored in dirlist2.txt
  3. c:\main\dir *.* >> c:\main\dirlist3.txt Append or stores directory files below  to previous output.
  4. USES:-  backing up all directory file names.
Sample programme 1 :-

@ECHO OFF 
:: create file name and storing output to dirlist1.txt
:: you have to create file name dirlist1.txt by using notepad,  before running this bat file.

c:\main\dir *.* >> c:\main\dirlist1.txt
c:\main\dir *.* >> c:\main\dirlist1.txt
c:\main\dir *.* >> c:\main\dirlist1.txt
c:\main\dir *.* >> c:\main\dirlist1.txt

exit


Sample programme 2:-

This programme will create automaticaly-new file name and stores content of directory,
Every time you run this will create NEW file and store the content of file names to dirlist2.txt.
Old file will be deleted. ( To avoid of deleting use >> to append file names one-by-one )

@ECHO OFF
:: Store file listing to dirlist2.txt. This file name will create automaticaly.

c:\main\dir *.* > c:\main\dirlist.txt

   exit


No comments:

Post a Comment

HOW TO BACKUP YOUR ALL DIRECTORY IN YOUR COMPUTER AND FILE NAMES:-

HOW TO BACKUP YOUR ALL DIRECTORY IN YOUR COMPUTER AND FILE NAMES:-   Syntax         tree   /f Description:- Displays names of files in a dir...