Categories
MacOS tech

Modifying file/folder creation date in MacOS

I spent hours and hours trying to figure out what was wrong with my newly rsync’ed music library tonight.

First, the list of problems: I had a large number of greyed out folders that were owned by the user/group of ‘_unknown’ (in ls), couldn’t be modified, and had odd extended file attributes. They looked like this in the finder (I forgot to get a screenshot of terminal, so you’ll just have to trust me):

finder shows the greyed out and inaccessible folders.
finder shows the greyed out and inaccessible folders.

How I attacked the problem:

1) The first thing I did was get rid of the unneeded folder ACLs with this:

chmod -N /path/to/directory/

2) That didn’t do it, so it seemed that the file ownership was the mostly likely cause. chown, however, wasn’t changing the ownership of the folders. A quick google revealed this thread, which lead me to try the following, which enabled permissions on the drive itself:

sudo /usr/sbin/vsdbutil -a /path/to/volume/

Then I could change the ownership/group of the files and folders, but even with correct ownership on the folders I still couldn’t get finder to display the folders correctly, and more importantly: I couldn’t add the music to my music library.

I got a hint, though, when I noticed that the ‘Created’ date showed as January 24th, 1984:

finder shows the creation date as 01/24/1984
finder shows the creation date as 01/24/1984

Through much searching it was becoming increasingly apparent that not many people had encountered a problem with the creation date getting mucked up on their folders. The only real solution I’d found was either to pay for a program to take care of it, or to duplicate each individual folder and delete the old one.

I didn’t like either of those options, so I started digging through apple’s command line utilities for one that would display and modify file attributes. Thankfully, I found GetFileInfo and SetFile. While I could have written a quick script to only modify the ones that needed to be corrected, I didn’t care too much about the existing creation dates, so I just updated the timestamps.

First, I used GetFileInfo with the ‘-d’ flag to just display the timestamp format:

bash-3.2$ GetFileInfo -d /Volumes/BackupsAndStuff/musicMaster/Muse/
12/12/2007 18:58:00

Next I ran SetFile, again with the -d flag, to update the timestamp:

SetFile -d "12/12/2007 18:58:00"  /Volumes/BackupsAndStuff/musicMaster/Zero\ 7/

and tested to make sure it had actually worked:

bash-3.2$ GetFileInfo -d /Volumes/BackupsAndStuff/musicMaster/Zero\ 7/
12/12/2007 17:58:00

And then I took care of the rest of them, and all was well:

SetFile -d "12/12/2007 18:58:00" /Volumes/BackupsAndStuff/musicMaster/*

I sincerely hope that this helps the next person to come up against this problem. Of note: I already had Xcode installed, but if you don’t you’ll need to install it (which can be done through the app store).