quietUSB.zsh 710 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/zsh
  2. #
  3. # Takes the volume name as argument.
  4. #
  5. DRIVE="$1"
  6. usage()
  7. {
  8. printf "usage: quietusb [VOLUME_NAME]"
  9. }
  10. #
  11. # Ensure drive exists.
  12. #
  13. if [ ! -d /Volumes/"$DRIVE" ] || [ -z "$1" ]; then
  14. usage
  15. exit
  16. else
  17. :
  18. fi
  19. ######
  20. # MAIN
  21. ######
  22. #
  23. # Disable Spotlight indexing.
  24. #
  25. mdutil -i off /Volumes/"$DRIVE"
  26. #
  27. # Remove init / metadata files / directories.
  28. #
  29. rm -rf /Volumes/"$DRIVE"/.fseventsd \
  30. /Volumes/"$DRIVE"/.metadata_never_index \
  31. /Volumes/"$DRIVE"/.Spotlight-V100 \
  32. /Volumes/"$DRIVE"/.Trashes
  33. #
  34. # Overwrite metadata files with dummy files.
  35. #
  36. touch /Volumes/"$DRIVE"/.fseventsd \
  37. /Volumes/"$DRIVE"/.metadata_never_index \
  38. /Volumes/"$DRIVE"/.Trashes