Skip to content

Instantly share code, notes, and snippets.

@skysan87
Last active January 23, 2019 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skysan87/d47303c75531c7d9c66d3e86da8cd05b to your computer and use it in GitHub Desktop.
Save skysan87/d47303c75531c7d9c66d3e86da8cd05b to your computer and use it in GitHub Desktop.
カウントダウンタイマー
@echo off
rem 実行環境: Windows 7 x64(日本語環境)
rem 留意事項:文字コード:UTF-8(BOMなし)、日本語は文字化けする
rem 環境を汚染しないようにローカル化
setlocal
rem タイトル変更
title Countdown Timer
set ISNUMERIC=0
set COUNTER=1
rem 入力待ち
set /p COUNT_MINIUTES="How long? (in minutes):"
if "%COUNT_MINIUTES%"=="" (
exit
)
rem 数値判定(整数のみ)
rem tokens=1 1文字目を読み込む
rem delims=0123456789 数字を区切り文字とし、文字列を分解する
rem 参考: http://d.hatena.ne.jp/acetaminophen/20150810/1439152054
for /F "tokens=1 delims=0123456789" %%i in ("%COUNT_MINIUTES%") do (
set hoge=%%i
)
rem 文字列が存在しなければ、真となる
if "%hoge%"=="" (
set ISNUMERIC=1
)
if %ISNUMERIC% equ 0 (
echo Not numeric.
exit
)
rem NOTE: if文の中で変数の変更するはif文を抜けたときに反映される
set /a COUNTER=%COUNT_MINIUTES%*60
rem カウントダウン
for /L %%a in (%COUNTER%,-1,1) do (
echo Countdown... : %%a
timeout /t 1 > nul
cls
)
endlocal
rem アプリを起動するなりなんなり
rem echo time up!
rem pause
start "" "finish_msg.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment