-- Drive Visibility Toggler
-- BP 2010 - November 2014 (Yosemite tightened restrictions, so System Events won't set visible flag easily any more)
-- Toggles the desktop visibility of an individual drive. This does NOT affect visibility in file Dialogs.
-- Finder prefs for visibility are preserved, simply superceded by this lower level flag.
-- Won't work on boot partition, or bootable partitions without either sudo or admin privileges. (UNIX -> GetFileInfo SetFile)
-- Using Admin privileges, it will sometimes ask for admin password. That's as it should be.
-- If you use it on a network drive, visibility changes will affect all users. Don't be a jerk.
-- Invisibility will survive unplugging drive and attaching it to another Mac.
-- You must manually target the drive by inserting its name correctly in the next line of code.
------------------------------------------------------------------------------------
----------- user settable variables
set drivename to "Ceres" -- **** Set this to the name of the drive you want to act on. ****
----------- end of user settable variables
------------------------------------------------------------------------------------
set quoteddrivename to quoted form of drivename
try
set attribs to (do shell script "GetFileInfo -a /Volumes/" & quoteddrivename) as text
on error
beep (1)
return
end try
try
considering case
if attribs contains "v" then
do shell script "SetFile -a V /Volumes/" & quoteddrivename with administrator privileges
else
do shell script "SetFile -a v /Volumes/" & quoteddrivename with administrator privileges
end if
end considering
on error
beep (1)
return
end try
do shell script "killall Finder" -- Restart the Finder to show changed visibility This is not necessary as long as I toggle the Finder's vis prefs.