2016年3月20日 星期日

將 Ping 結果寫入日期檔名

:引用網址http://ithelp.ithome.com.tw/question/10144233

@echo off
setlocal

:: FQDN Address
set "FQDN=168.95.1.1"

:: tempLog location
set "LOG=log.txt"

:: Date/Time Define
set "FULLDATE=%date:~0,4%-%date:~5,2%-%date:~8,2%"
set "FULLTIME=%time:~0,2%%time:~3,2%%time:~6,2%"

:: Write Ping result in templog
>"%LOG%" ping -n 5 -w 1000 %FQDN%

:: rename file-name to date-time format  
rename "%LOG%" %FULLDATE%_%FULLTIME%.log


沒有留言:

張貼留言