I was using Gemini today to try to clear out some duplicate files and I noticed that I was having permissions issues with some of the directories I was searching. These directories had traveled across multiple Macs and external drives, so I wasn’t terribly surprised – except that there was one folder I could seem to get access to with Finder. It was grayed-out and inaccessible, though I could navigate to it through Terminal. I tried making myself the owner, I tried settings the permissions to 777, I tried editing the extended attributes (there were none).
Finally I found a solution which uses SetFile – part of the Xcode installation. At some point, it seems a file transfer was interrupted in the middle of copying this directory and it turns out that Finder temporarily sets the created date on a file or directory to a really old value which renders the file or folder inaccessible (probably so you don’t get in and much around while the data is copying). When a file transfer is ungraceful interrupted, Finder might not know or might not be able to correct the date. The article I found said that the date would be set to 06/13/1946, but when I checked this particular directory, it was set to January 24, 1984. Either way, it was way too old.
sh-3.2# SetFile -d 22/02/2014 Music/ #(Or any reasonably recent date)
That cleared the problem right up!
If you don’t have Xcode tools installed, you can actually achieve the same thing with touch.
sh-3.2# touch -t 201402221100 Music/
The -t flag tells touch to modify the created date (-mt will change the modified date) and the numbers indicate the year, month, date, hour, and minute (YYYYMMDDhhmm).