Scenario
Can somebody remember me what was the command to create an empty file in MSDOS using .BAT file?
Solution #1
echo. 2>EmptyFile.txt
copy NUL EmptyFile.txt
Solution #2
DOS has a few special files (devices, actually) that exist in every directory, NUL
being the equivalent of UNIX's /dev/null
: it's a magic file that's always empty and throws away anything you write to it. Here's a list of some others; CON
is occasionally useful as well.
To avoid having any output at all, you can use:
copy /y NUL EmptyFile.txt >NUL
/y
prevents copy
from asking a question you can't see when output goes to NUL
.
Solution #3
TYPE NUL > EmptyFile.txt
TYPE commad is usually used to view the content of a text/log files.
Solution #4
fsutil file createnew file.cmd 0
The file system utility "fsutil" is a suite of command-line operations for displaying and managing certain file and drive properties.
NOTE: fsutil needs administrative privileges (especially on Windows Vista and Windows 7) to run properly and let you do file system tasks.
Solution #5
REM. > empty.file
REM stands for "remark", it is usually used to insert comments in batch file scripts.
Solution #6
You can use a TYPE command instead of COPY.
Try this:
TYPE File1.txt > File2.txt
Where File1.txt is empty.
SOURCE | LINK | LANGUAGE | ENGLISH |