我想创建新文件并在其中添加信息。但是一开始我想清除所有的信息。所以我写了:如何使用批处理脚本创建没有新行的空文件?
@if "%DEBUG%" == "" @echo off
@rem ############################################
@rem # Create new empty file #
@rem ############################################
:setup
if "%OS%"=="Windows_NT" setlocal
SetLocal EnableDelayedExpansion
goto create
:create
@cmd /c echo(>%temp%\hosts
goto end
:end
if "%OS%"=="Windows_NT" endlocal
PAUSE
但是当我打开该文件有领先空行
<empty line>
SomeInfo
如果仅仅是空行。 如何创建没有前导空行的新文件?
可能的重复http://stackoverflow.com/questions/210201/how-to-create-empty-text-file-from-a-batch-file – Rafael 2014-11-04 13:29:54