I'm trying to add one year to the modification and creation dates to all files of a folder.
I found many examples to modify a whole date (not only the year).
How can I add one year to the creation/modification to all files in a folder?
I'm on OS X.
I'm trying to add one year to the modification and creation dates to all files of a folder.
I found many examples to modify a whole date (not only the year).
How can I add one year to the creation/modification to all files in a folder?
I'm on OS X.
touch has an adjust option (-A), but that is sadly limited to 99 hours, 99 minutes, and 99 seconds. But repeated applications can get you what you want:
in Bash:
# assume a year is 365 days for day in {1..365}; do touch -A 240000 folder/* done # on a mac with Xcode cmdline tools installed, # set creation time to mtime: for f in folder/* ; do SetFile -d "$(GetFileInfo -m $f)" $f done SetFile for that: apple.stackexchange.com/a/99599/205028 If you're using GNU date, you can try something like
for file in *; do echo "$file" $(date -d "$(date -r $file) 1 year"); done (this really ought to be cleaned up for special characters and formatting) You're not going to get creation date on most file systems.