[Tutor] Deleting specified files using a python program...help with code?

Saad Javed sbjaved at gmail.com
Tue Jul 1 09:41:21 CEST 2008

Thankyou cedric!

On 6/29/08, Saad Javed <sbjaved at gmail.com> wrote:
> I transfer files a lot between my windows and linux partitions...these
> folders sometimes contain *.db and *.ini files which are not recognized or
> used by linux. So i tried to write a program to crawl through my home dir
> and remove these files...I'm *very* new to programming and python so please
> be gentle. Here is the code:
> *import os
> list = ['*.ini', '*.db']
> for root, dirs, files in os.walk('/home/saad'):
> **for list in files:
> **os.remove(os.path.join('root', 'list'))
> print 'done'*
> Unfortunately its a bit too efficient and nearly wiped my home dir before i
> manually killed it. Again...treat me like a super noob.
> Saad

Sent from Gmail for mobile | mobile.google.com

More information about the Tutor mailing list