2

I am aware that you can delete Mac OS X hidden files/folders (such as /.Spotlight-V100 or .DS_Store) on a USB drive using various scripts. But then the hidden files/folders get added again before you eject it.

Is there any way to prevent this, and if so - how?

Oliver Salzburg
  • 86,445
  • 63
  • 260
  • 306
gadgetmo
  • 766
  • 4
  • 9
  • 24
  • Are you talking about specific files? – Oliver Salzburg May 26 '12 at 13:05
  • @OliverSalzburg the ones that OS X adds automatically. http://www.westwind.com/reference/OS-X/invisibles.html. all of them. – gadgetmo May 26 '12 at 13:06
  • It might be helpful if you [put the names of the hidden files in your question](http://superuser.com/posts/429091/edit). That way people will quickly know what you mean. – Oliver Salzburg May 26 '12 at 13:13
  • possible duplicate of [How to prevent Mac OS X creating .DS_Store files on non Mac (HFS) Volumes?](http://superuser.com/questions/47918/how-to-prevent-mac-os-x-creating-ds-store-files-on-non-mac-hfs-volumes) – Daniel Beck May 26 '12 at 13:40
  • some help here too [How disable mac snow leopard creating .Spotlight-V100 and .Trash folders in USB Flash Drivers?](http://superuser.com/questions/89556/how-disable-mac-snow-leopard-creating-spotlight-v100-and-trash-folders-in-usb) – Jeremy W May 26 '12 at 17:11
  • Duplicate of: [How disable creating .Spotlight-V100 and .Trash folders on external drive?](http://superuser.com/q/89556/87805) – kenorb Apr 08 '15 at 19:09

1 Answers1

3

To prevent /.Spotlight files you must prevent Spotlight fron indexing external drives.

To do this for a specific drive add a file called .metadata_never_index to the root directory of the removable drive.

You can also completely prevent spotlight indexing but I figured that was not what you were looking for.

To prevent .DS_Store files from being created:

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

More Info Here (And More files that you can prevent) and Here

jds
  • 662
  • 4
  • 13