Removing .DS_Store files from mac folders

David Pratt fairwinds at
Thu Mar 2 03:14:51 CET 2006

Hi. I'm trying to clean files for packaging on mac using os.path.walk 
and want to clean the .DS_Store files that are hidden from view but 
could end up in code that I produce.

# Clean mac .DS_Store
     if current_file == '.DS_Store':
         print 'a DS_Store item encountered'

My code walks the folders properly and print prints the statement when a 
.DS_Store file is encountered but the os.remove does not get rid of the 
file. I have previously cd'd into the folder and can remove all by doing 
which does work

system('find . -name .DS_Store -exec rm {} \;')

but I am walking the folders to do a few more things. I can't figure why 
remove is not removing.


More information about the Python-list mailing list