Hey, I want to make a simple program which changes whether hidden files are shown or not, and I want to be able to check whether they are so I can determine whether to show or hide the files.
Oh also can you tell me - do the hidden file settings change the account or the computer if I’m on a network.
Give this a try
set state to do shell script "defaults read com.apple.finder AppleShowAllFiles"
if state is not "YES" then
do shell script "defaults write com.apple.Finder AppleShowAllFiles YES;KillAll Finder;"
else
do shell script "defaults write com.apple.Finder AppleShowAllFiles NO;KillAll Finder;"
end if
This will pretty much toggle displaying hidden files on and off.
Excellent that’s just what I wanted. Thanks very much.
Not that its needed, but I wanted to do the same thing, but without an if statement so this works, but the try is essentially serving the same purpose
try
set state to do shell script "defaults read com.apple.finder AppleShowAllFiles" as boolean
on error
set state to false
end try
do shell script "defaults write com.apple.Finder AppleShowAllFiles -bool " & ((not state) as string) & ";KillAll Finder;"