第一种:
1、 @echo off
rem 假设系统日期格式是:yyyy-mm-dd week
rem 假设系统时间格式是:hh:mi:ss.ms
set strDate=%date:~0,10%
set strTime=%time::=.%
set strNow=%strDate%.%strTime%
>%strNow%.txt echo ./off/* 【这里需要输入任意字符】
>>%strNow%.txt echo ----------------
>>%strNow%.txt echo ---T E S T---
>>%strNow%.txt echo -----------------
红色部分也可写成:
echo ----------------------->>%strNow%.txt
echo test-test-test-test>>%strNow%.txt
echo ----------------------->>%strNow%.txt
第二种:
1、@echo off
rem 假设系统日期格式是:yyyy-mm-dd week
rem 假设系统时间格式是:hh:mi:ss.ms
set strDate=%date:~0,10%
set strTime=%time::=.%
set strNow=%strDate%.%strTime%
>%date%%time%.txt
>>%date%%time%.txt echo ----------------
>>%date%%time%.txt echo ---T E S T---
>>%date%%time%.txt echo -----------------
红色部分也可写成:
echo ----------------------->>%dat%%time%.txt
echo test-test-test-test>>%dat%%time%.txt
echo ----------------------->>%dat%%time%.txt
第三种比较简单(只能创建以日期命名的文本)
@echo off
echo ------->>%date:~0,4%%date:~5,2%%date:~8,2%-网易163.txt(后文以test.txt代)
echo 这个是监控:www.163.com主站>>test.txt
echo 时间:%date%%time%>>test.txt
echo ping www.163.com--网站的信息如下>>test.txt
各种命令>>test.txt
........
%date%规格是2014-03-14,年0始4末,月5始7末,日8始10末,年取4位,月日取2位。
以上随便写写记记,能用到的情况不多。命令每行都加test.txt太麻烦,dos下面有没有用1个命令就完成任务?
转载于:https://blog.51cto.com/594163/1376069