Deleting files with wildcards

richard_chamberlain richard_chamberlain at ntlworld.com
Wed Jul 26 12:29:32 EDT 2000


Hi Manfred,

import glob,os

filelist=glob.glob('c:/*.txt')
for file in filelist:
    os.remove(file)

Richard
Manfred Pisecky <pisecky at tttech.com> wrote in message
news:397f046d.193858654 at news.atnet.at...
> Hello everyone!
>
> I have to delete a bundle of files, e.g. *.txt in a portable way (it
> must work for Linux and NT).
>
> I use Python 1.5.2. and have not found a way to either delete files
> with wildcards or to read the directory content (and do it file by
> file).
>
> Is there a portable way in 1.5.2 ?
>
> Thanks,
> Manfred Pisecky





More information about the Python-list mailing list