Content writing to files is also done with the help of the double redirection filter >>. This filter can be used to append any output to a file. Following is a simple example of how to create a file using the redirection command to append data to files.
@echo off echo "This is the directory listing of C:\ Drive">C:\new.txt dir C:\>>C:\new.txt
In the above example, you can see that the first echo command is used to create the file using the single redirection command whereas the DIR command is outputted to the file using the double redirection filter.
If you open the file new.txt on your C drive, you will get the contents of your C drive in this file plus the string “This is the directory listing of C:\ Drive” . Following is a sample output.
"This is the directory listing of C:\ Drive" Volume in drive C is Windows8_OS Volume Serial Number is E41C-6F43 Directory of C:\ 12/22/2015 09:02 PM <DIR> 01 - Music 06/14/2015 10:31 AM <DIR> 02 - Videos 09/12/2015 06:23 AM <DIR> 03 - Pictures 12/17/2015 12:19 AM <DIR> 04 - Software 12/15/2015 11:06 PM <DIR> 05 - Studies 12/20/2014 09:09 AM <DIR> 06 - Future 12/20/2014 09:07 AM <DIR> 07 - Fitness 09/19/2015 09:56 AM <DIR> 08 - Tracking 10/19/2015 10:28 PM <DIR> 09 – Misc