Help us understand the problem. What is going on with this article?

MacOSXでファイルの作成日時と更新日時を変更する

More than 5 years have passed since last update.

Mac OSXで setfile コマンドを使うとファイルの作成日時と更新日時を変更できるらしい。


SetFile(1) Mac OS X Developer Tools Manual Pageを見ると、 -d で作成日時が、 -m で更新日時が変更できるようです。

たとえばこんなファイルと作ってみます。

[mazgi@BRUICHLADDICH] $ touch A.LostLogia
[mazgi@BRUICHLADDICH] $ ls -lT A.LostLogia
-rw-r--r--  1 mazgi  staff  0 Jan 28 13:01:13 2014 A.LostLogia
[mazgi@BRUICHLADDICH] $ ls -lUT A.LostLogia
-rw-r--r--  1 mazgi  staff  0 Jan 28 13:01:13 2014 A.LostLogia

Screen Shot 2014-01-28 at 1.01.30 PM.png

早速 setfile -dsetfile -m を実行してみます。
ちなみにMac OSXの date コマンドは -v[+-]num[ymwdHMS] オプションでGNU版dateのように「○年前」「○日後」の指定ができるようです。

[mazgi@BRUICHLADDICH] $ setfile -d "$(date -v-100y +'%m/%d/%Y %H:%M:%S')" A.LostLogia
[mazgi@BRUICHLADDICH] $ setfile -m "$(date -v-64y +'%m/%d/%Y %H:%M:%S')" A.LostLogia
[mazgi@BRUICHLADDICH] $ ls -lUT A.LostLogia
-rw-r--r--  1 mazgi  staff  0 Jan 28 13:14:13 1914 A.LostLogia
[mazgi@BRUICHLADDICH] $ ls -lT A.LostLogia
-rw-r--r--  1 mazgi  staff  0 Jan 28 13:14:23 1950 A.LostLogia

Screen Shot 2014-01-28 at 1.14.28 PM.png

これで100年前に作られて64年前に変更されたことになりました!

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした