Code of the Day: DOS Open an existing file or create it if it doesn’t exist

REM filename: openAndORCreateFileTXT.bat
rem\ >> file.txt && file.txt

The following will open a existing file named file.txt. However, it if doesn’t exist then it will create it for you then open it. This is very useful.

“rem\” Let’s you return a empty character.
“>> file.txt” appends the returned value on the left hand side, which in this case is nothing.
“&& file.txt” once the left hand operation is done, then open the file ( file.txt).

(Page view Count: 6)