http://www.perlmonks.org?node_id=1206788


in reply to Modifying a directory file

If it was me, I would just move/rename the directory itself somewhere out of the way on the same filesystem, then create a new dir with the correct name and permissions, and move all the files, except the impossible one, back to the new directory.

If you *really* need to actually fix the directory entry, then a quick+dirty solution would be to treat the filesystem's raw device as a block file (i.e. the OSX equivalent of Linux's /dev/sda, whatever that is), then if the file name is distinct enough (e.g. "\0\0\0\0some_long_name"), search for that text within the device, and if it's only found once, then rewrite the block holding that string with the \0's replaced with X or whatever (Preferably done with the filesystem unmounted).

Dave.