How can creation times be preserved while copying?
When I copy in Terminal, rsync -t and cp -p only preserve modification times. I am running macOS 11.3.
MacBook Air 13″, macOS 11.3
When I copy in Terminal, rsync -t and cp -p only preserve modification times. I am running macOS 11.3.
MacBook Air 13″, macOS 11.3
ditto didn't preserve creation times, only modification times.
rsync -avX returned this error:
rsync error: syntax or usage error (code 1) at /System/Volumes/Data/SWE/macOS/BuildRoots/2288acc43c/Library/Caches/com.apple.xbs/Sources/rsync/rsync-55/rsync/main.c(1337) [client=2.6.9]
Hi jjjefff,
To preserve creation times while copying files in macOS, you can use the `ditto` command in Terminal. Here's how you can do it:
zsh
ditto -V source_directory destination_directory
Replace `source_directory` with the path to the directory you want to copy from and `destination_directory` with the path to the directory you want to copy to.
The `-V` option is optional and enables verbose mode, which provides more detailed output during the copying process.
Using `ditto` preserves not only modification times but also resource forks and other metadata, including creation times, when copying files and directories in macOS.
Alternatively, if you prefer to use `rsync`, you can add the `-X` option to preserve extended attributes and resource forks:
zsh
rsync -avX source_directory/ destination_directory
Again, replace `source_directory` and `destination_directory` with the appropriate paths.
These commands should help you preserve creation times while copying files and directories in macOS.
How can creation times be preserved while copying?