Can you hide hidden files in specific folders (like the desktop) while keeping them shown everywhere else?

I work with hidden files all the time, but I like an uncluttered desktop. It would be nice to make files like .DS_Store, and .localized invisible just on the Desktop.

Please note I am already aware of this trusty old terminal standby:

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

Setting that flag to FALSE applies to everything in the system. My goal is to make an exception for the Desktop. Any suggestions?


Although i'm unsure how to fulfill your exact request, I use this tiny widget which gives 1 button access to hide/show hidden files.


chflags hidden ~/Desktop/hideme

This makes the file/folder invisible from the Finder and save/open panels. You can use {command}{shift}. to toggle visibility during save/open.


My approach to this was to set Finder to generally show invisible files, and then explicitly set the invisible flag on files/folders on the Desktop which match certain criteria (.*, Icon, etc).

But this approach failed, as Finder then consequently not only shows files hidden because they start with a dot, but also those which have the invisible flag in their filesystem entry.

Nevertheless I post this idea to you, maybe it leads you to a solution.

# Set Finder to show all hidden files
# Only needs to be executed one time.
defaults write com.apple.finder AppleShowAllFiles ON

# Then explicitly flag certain files on the Desktop as invisible
# Run this at every login or at certain intervals (cron job)
/usr/bin/SetFile -a V ~/Desktop/.* ~/Desktop/Icon ~/Desktop/OtherPatternForHiding

This does not answer your very specific question but provides an alternative solution. Assuming you want to have easy and quick access to the hidden files and not have them open all the time, which is not recommended anyway.

Here is a little script that Automates the process down to a single click to Show or Hide. It eliminates:

1-possible problems with hidden files showing all the time

2-opening terminal and typing the show hidden files, command each time.

3-Extremly users friendly.

Install this as application onto your dock for easy and fast access.

-- AppleScript to toggle hidden "." files
-- Submitted by Baltwo on Apple Support Community

try
    do shell script "defaults read com.apple.finder AppleShowAllFiles"
on error
    do shell script "defaults write com.apple.finder AppleShowAllFiles 0"
end try

if (do shell script "defaults read com.apple.finder AppleShowAllFiles") is equal to "0" then
    do shell script "defaults write com.apple.finder AppleShowAllFiles 1"
else
    do shell script "defaults write com.apple.finder AppleShowAllFiles 0"
end if

do shell script "killall Finder"