How to ease the reading of your batch files when using redirections
You maybe already discovered that the flow of your batch file sometimes
becomes a bit unreadable when using a lot of redirections to files. Ex:
echo This is my batch file
echo:
echo This is first line of first file > myfile1.out
echo I will list all files to file 2
dir > myfile2.out
echo This should the 2nd line of first file >> myfile1.out
attrib *.* >> myfile2.out
Are you able to easily see where all commands are redirected to ?
Here is another way of writing the same batch file which (amazingly)
also works:
echo This is my batch file
echo:
> myfile1.out echo This is first line of first file
echo I will list all files to file 2
> myfile2.out dir
>> myfile1.out echo This should the 2nd line of first file
>> myfile2.out attrib *.*
Isn't that easier ?
|