0
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 1 year has passed since last update.

Windowsの標準機能でファイル作成日時を変更

Last updated at Posted at 2020-11-25

PowerShell

ファイルパス内にスペースがあっても問題ありません。

Set-ItemProperty "ファイルパス" -name CreationTime -value "2020/01/01 00:00"

コマンドプロンプト

こちらもファイルパス内にスペースがあっても問題ありません。

powershell Set-ItemProperty 'ファイルパス' -name CreationTime -value '2020/01/01 00:00'

コマンドプロンプトでいける = batファイルが作れます。

『作成日が古いファイルを自動削除する機能』系のテストで、頻繁に作成日が古いファイルを作りたい時は便利です。

蛇足

ドラッグドロップした複数ファイルの作成日を一括変更するbatファイル作ろうとしました。(下記)

for %%f in (%*) do (
	powershell Set-ItemProperty %%f -name CreationTime -value '2020/01/01 00:00'
)

動くことは動く……しかしファイルパスにスペースが入るとエラーになる。
(PowerShellにファイルパスを渡す時にダブルクオテーション付きで渡しているらしく……上手い回避策が見つからなかった)

batにこだわらずにC#でexe作っちゃった方が簡単な気がした…(´・ω・`)

バージョン

Windows10 Pro バージョン1909 OSビルド19042.630
PSVersion 5.1.19041.610

0
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
0
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?