Sometimes the Mac Finder can get its knickers in a twist about files that you ought to be able to open just fine but Finder says no. You may see a message that says “Item XYZ is used by Mac OS X and can’t be opened.”
This can happen if the Finder is in the middle of a copy and the source disk is suddenly disconnected. During a copy the Finder sets a special type/creator code on files, and when the copy completes the proper type/creator code is restored. But if the copy is interrupted then sometimes instead of recovering gracefully the Finder leaves the files with their temporary attributes.
So if you do have these “ghost” files, here is a bit of command-line magic to remove the Finder’s temporary attributes (you would need to change the “
mdfind -onlyin /path/to/files -0 "kMDItemFSTypeCode==brok && kMDItemFSCreatorCode==MACS" | xargs -0 -n1 xattr -d com.apple.FinderInfo
(This is a single command, all on one line, which you type in Terminal.app.)
What this does is use the Spotlight tool to find only files that have a Mac file type of “brok” and a creator code set to “MACS”. Then for each file we remove the Finder attributes (which means the Finder reverts to using the file-name’s extension when deciding how to open a file).
-onlyin flag is used to restrict the search to a particular folder and its sub-folders, a belt and braces approach to making sure we only fix the files we are interested in.
This post was suggested by @hobbsy, who had probs with RAW pictures he had copied across disks.
Although the way I showed him how to do this originally was needlessly convoluted because I forgot what one can do with
Although the way I showed him how to do this was so much simpler because it was wrapped in a drag-and-drop Mac application created using Sveinbjörn Þórðarson’s Platypus, so no need to type the wrong thing into the shell and accidentally delete everything.