macOS でのダミーファイル生成
ダミーファイルを作る
macOS 上でダミーファイルを作る場合、 mkfile コマンドを使うのが簡単.
コマンドの書式
mkfile <サイズ> <ファイル名>
サイズには単位を指定することができ、 b (Byte)、 k (KB)、 m (MB)、 g (GB) を数値の後ろに付与してやればよい.
作成例
$ mkfile 1m dummy.txt
ファイル属性(作成日時・更新日時 etc.)を変更する
ファイルの更新日時を変更するだけならば touch コマンドのほうが簡単なようだが、 macOS には setfile というファイル属性 (作成日時、更新日時、作成者) を変更するためのコマンドが存在する.
setfile コマンドの使い方については以下の通り.
Usage: SetFile [option...] file...
-a attributes # attributes (lowercase = 0, uppercase = 1)*
-c creator # file creator
-d date # creation date (mm/dd/[yy]yy [hh:mm[:ss] [AM | PM]])*
-m date # modification date (mm/dd/[yy]yy [hh:mm[:ss] [AM | PM]])*
-P # perform action on symlink instead of following it
-t type # file type
Note: The following attributes may be used with the -a option:
A Alias file
B Bundle
C Custom icon*
D Desktop*
E Hidden extension*
I Inited*
M Shared (can run multiple times)
N No INIT resources
L Locked
S System (name locked)
T Stationery
V Invisible*
Z Busy*
Note: Items marked with an asterisk (*) are allowed with folders
Note: Period (.) represents the current date and time.
Note: [yy]yy < 100 assumes 21st century, e.g. 20yy
日時は mm/dd/yyyy HH:MM:SS という書式で指定するが、 mm/dd/yyyy HH:MM や mm/dd/yyyy のような省略形でも問題ない.
使い方は以下の通り.
# ファイルの作成日を変更する
$ setfile -d "2023/04/21 13:18:00" dummy.txt
# ファイルの更新日を変更する
$ setfile -m "2023/04/21 13:18:00" dummy.txt