1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

windowsでtouchコマンド

Posted at

Windowsにtouchコマンドがほしい

Windowsのコンソールでファイルだけとりあえず欲しいとき/更新日時を更新したい時にtouchしたくなったあなた(私)へ。

touch.bat
@echo off
if exist %1 goto update

rem ファイルの作成
:new
copy nul %1 > nul
goto end

rem 更新日時の更新
:update
copy %1+ > nul

:end
@echo on
X:\hoge>dir /w
ドライブ X のボリューム ラベルは ボリューム です
 ボリューム シリアル番号は FFFF-FFFF です

 x:\hoge のディレクトリ

[.] [..] touch.bat
X:\hoge>touch.bat aaaa.txt
X:\hoge>dir
nob-aoki:[d:\programing\bin\hoge]$ dir
 ドライブ D のボリューム ラベルは ボリューム です
 ボリューム シリアル番号は FFFF-FFFF です

 X:\hoge のディレクトリ

1234/05/06  07:08    <DIR>          .
1234/05/06  07:08    <DIR>          ..
1234/05/06  07:08                 0 aaaa.txt
               1 個のファイル                   0 バイト
               2 個のディレクトリ  999,999,999 バイトの空き領域

X:\hoge>touch.bat aaaa.txt
X:\hoge>dir
nob-aoki:[d:\programing\bin\hoge]$ dir
 ドライブ D のボリューム ラベルは ボリューム です
 ボリューム シリアル番号は FFFF-FFFF です

 X:\hoge のディレクトリ

1234/05/06  07:08    <DIR>          .
1234/05/06  07:08    <DIR>          ..
1234/09/10  11:12           0 aaaa.txt
               1 個のファイル                   0 バイト
               2 個のディレクトリ  999,999,999 バイトの空き領域

X:\hoge>dir
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?