Removing .DS_Store files from mac folders
Ben Cartwright
bencvt at gmail.com
Wed Mar 1 22:16:21 EST 2006
David Pratt wrote:
> Hi Ben. Sorry about the cut and paste job into my email. It is part of a
> larger script. It is actually all tabbed. This will give you a better idea:
>
> for f in file_names:
> current_file = os.path.basename(f)
> print 'Current File: %s' % current_file
>
> # Clean mac .DS_Store
> if current_file == '.DS_Store':
> print 'a DS_Store item encountered'
> os.remove(f)
I'm no Mac expert, but could it be that OSX is recreating .DS_Store?
Try putting this above your os.remove call:
import os.stat
print 'Last modified:', os.stat(f)[ST_MTIME]
Then run your script a few times and see if the modified times are
different.
You might also try verifying that you get an exception when attempting
to open the file right after removing it.
--Ben
More information about the Python-list
mailing list