批处理文件操作

1、批处理生成文件:

@echo off 
type nul>newfile.txt

2、向文件中写入数据

@echo off 
cd /d %~dp0
del newfile.txt
type nul>newfile.txt

@echo 1234567890>>newfile.txt
@echo abcdefghij>>newfile.txt
@echo %date%>>newfile.txt

运行结果:

 1234567890
abcdefghij
2017/03/01 周三

注意:此处 > 和>> 都是重定向,但 >表示覆盖原来数据,>> 表示末尾追加

3、读取文件并显示:

@echo read newfile info:
for /f %%i in ('type "newfile.txt"') do @echo %%i


你可能感兴趣的:(批处理文件操作)