Hey everyone,
I have beed searching all over trying to find a simple script to hide and show folders in OS X. I started with a program that allowed you to browse hidden folders. Pretty simple... Then I saw that you could create / delete hidden folders. Pretty cool... But there was no scripts that I could find that would quickly let you make a folder visible and invisible... Untill now!
I am a novice scripter, so this might not be pretty but it works for me. Any help on error handlers, etc. would be greatly appreciated!!
I even made it password protected so when you compile it as an application and when it runs it asks for a simple password. Just set it where it says <INSERT PASSWORD>
Here it is:
Hope this is useful to a lot of people!
I have beed searching all over trying to find a simple script to hide and show folders in OS X. I started with a program that allowed you to browse hidden folders. Pretty simple... Then I saw that you could create / delete hidden folders. Pretty cool... But there was no scripts that I could find that would quickly let you make a folder visible and invisible... Untill now!
I am a novice scripter, so this might not be pretty but it works for me. Any help on error handlers, etc. would be greatly appreciated!!
I even made it password protected so when you compile it as an application and when it runs it asks for a simple password. Just set it where it says <INSERT PASSWORD>
Here it is:
Code:
-- This applescript helps you manipulate invisible folders easily.
-- Save this script as an application and launch it whenever you need to Hide, Show, or, Browse an invisible folder.
--Password Protected Script
set ChoicePass to text returned of (display dialog "Password" default answer "" buttons {"Cancel", "OK"} default button 2)
if (ChoicePass = "<INSERT PASSWORD>") then
-- ask user what he wants to do
set choice to button returned of (display dialog "Now You See It... Now You Don't..." buttons {"Make Visible", "Make Invisible", "Browse"} default button "Browse")
-- just browse his file system while showing invisible files/folders and open the selected invisible folder
if choice = "Browse" then
set x to (choose folder with invisibles) -- Browse invisible folders
tell application "Finder" to open x -- Open folder
else if choice = "Make Visible" then
tell application "Finder"
set FolderPath to (choose folder with invisibles) as alias -- sets file path to folder you select
set ParentFolder to container of FolderPath as text -- sets the parent folder of the folder you select
set NewFolderPath to FolderPath as text -- strips out the . from the file path
set AppleScript's text item delimiters to "."
set the item_list to every text item of NewFolderPath
set AppleScript's text item delimiters to ""
set NewFolderPath to the item_list as string
set AppleScript's text item delimiters to ""
end tell
try
do shell script "mv " & quoted form of the POSIX path of (FolderPath) & " " & quoted form of the POSIX path of (NewFolderPath)
on error the error_message number the error_number
display dialog "Error: The File IS Visible!" buttons {"OK"} default button 1
end try
else if choice = "Make Invisible" then
tell application "Finder"
set FolderPath to (choose folder) as alias -- sets file path to folder you select
set ParentFolder to container of FolderPath as text -- sets the parent folder of the folder you select
set Foldername to name of folder FolderPath as text -- sets the folder name as text
end tell
try
do shell script "mv " & quoted form of the POSIX path of (ParentFolder & Foldername) & " " & quoted form of the POSIX path of (ParentFolder & "." & Foldername)
on error the error_message number the error_number
display dialog "Error: The File IS Invisible!" buttons {"OK"} default button 1
end try
end if
end if
Hope this is useful to a lot of people!