Automatically remove a certain file from a given directory

Aug 06, '07 07:30:00AM

Contributed by: etatoby

Many of us have found a profiles.bin file in our home folders. Many think it is created by MS Office for some reason, but nobody knows for sure. Everybody hates it and tries to remove it, to no avail: the file will respawn the next time you open MS Office. The file is completely useless, as far as anybody can tell.

I don't suggest a solution to the issue, nor an explanation; just a cool workaround to have that file delete itself every time you open its containing folder. It does so by means of a Folder Action. Folder Actions are pieces of AppleScript code to be executed automatically every time you open or close a folder, or add/remove items to/from it.

Here's how to create the one we need. Open Script Editor (in Applications » AppleScript) and type the following script and then click Compile to test for (most) spelling mistakes:

on opening folder
  tell application "Finder" to delete file "profiles.bin" of home
end opening folder
Save the script as Delete profiles_bin somewhere appropriate, such as in Home » Library » Scripts » Folder Action Scripts (this is where Automator saves its folder actions), then open a Finder window. Control-clik on your home folder in the sidebar and select Enable Folder Actions. From the same menu, choose "Attach a Folder Action" and point it to the file you just saved

Done! Now every time you open your home folder in Finder, if a "profiles.bin" file is there, it will be deleted! Obviously, you could easily modify the above script to work on any other unwanted files that are automatically generated.

[robg adds: From what I can find on Google, it seems this issue only affects non-English versions of Office. I checked my machines, and none of them had the file. There are other solutions to this problem, of course. For instance, you could use Terminal and a cron job set to run once a day (or whenever) to check for and delete the file if found.]

Comments (3)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20070803144536276