Skip to content

Instantly share code, notes, and snippets.

@alecvance
Last active May 9, 2021 17:14
Show Gist options
  • Save alecvance/02c56e71c4c2dea9c1f22a88e32e8731 to your computer and use it in GitHub Desktop.
Save alecvance/02c56e71c4c2dea9c1f22a88e32e8731 to your computer and use it in GitHub Desktop.
bash script to fix creation dates in a directory (Mac OS X)
cd "$1"
for f in * ; do
SetFile -d "$(GetFileInfo -m $f)" "$f"
done
@alecvance
Copy link
Author

When importing files from my Zoom H4n pocket recorder, I was annoyed that the creation date for every file showed up as Unix time zero (as "Dec 31, 1969" to those of us west of GMT; "Jan 1 1970" for the rest of the world), so this is a quick script that will fix all the creation dates in the file specified by setting them to the same as the modification date. This is useful because the mod date will likely be updated but you might be interested in the date/time the actual recording was made.

Example command:
sh ./fix_creation_dates.sh /path/to/folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment