ホーム > ファイルの更新日を取得する

ファイルの更新日を取得するには %~ti を使います。

  1. バッチファイルで指定したファイルの更新日を表示します
  2. [バッチファイル]
    rem バッチファイルの引数に更新日を調べたいファイル名を指定します
    rem sample.bat c:\tips\timemachine.exe
    for %%i in (%1) do echo %%~ti

    --- 実行結果 ---
    2016/12/06 13:02

  3. 変数にバッチファイルで指定したファイルのサイズを設定します
  4. [バッチファイル]
    for %%i in (c:\tips\timemachine.exe) do set SIZE=%%~ti
    echo %SIZE%

    --- 実行結果 ---
    2016/12/06 13:02

  5. dir でファイルサイズを取得します
  6. C:\TIPS>dir c:\tips\timemachine.exe

    --- 実行結果 ---
    C:\TIPS のディレクトリ

    2016/12/06 13:02 1,985 timemachine.exe

確認したOS: Windows 10

↑ PAGE TOP