How to store files names in a directory???
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
- c:\main\dir *.* > c:\main\dirlist1.txt All listing of files stored in dirlist11.txt, instead of displayig in computer screen.
- c:\main\dir *.exe > c:\main\dirlist2.txt All *.exe file name stored in dirlist2.txt
- c:\main\dir *.* >> c:\main\dirlist3.txt Append or stores directory files below to previous output.
- USES:- backing up all directory file names.
@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
-----------------------
PAGE 01
PAGE 02

No comments:
Post a Comment