Removing .DS_Store files from mac folders

David Pratt fairwinds at eastlink.ca
Wed Mar 1 21:55:00 EST 2006


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)

Ben Cartwright wrote:
> David Pratt wrote:
> 
>># Clean mac .DS_Store
>>     if current_file == '.DS_Store':
>>         print 'a DS_Store item encountered'
>>	os.remove(f)
> 
> ...
> 
>>I can't figure why
>>remove is not removing.
> 
> 
> 
> It looks like your indentation is off.  From what you posted, the
> "print" line is prepended with 9 spaces, while the "os.remove" line is
> prepended with a single tab.  Don't mix tabs and spaces.
> 
> Also, shouldn't that be "os.remove(current_file)"?
> 
> --Ben
> 



More information about the Python-list mailing list