Removing .DS_Store files from mac folders

David Pratt fairwinds at eastlink.ca
Wed Mar 1 21:14:51 EST 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'
	os.remove(f)

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.

Regards,
David



More information about the Python-list mailing list