how to delete a file 3 months after downloading it in python

0

I have a script that allows to download several files from a URL. These files are placed directly in a folder that takes the name of the species entered by the user. I would like after 3 months this folder to be deleted in an automatic way.need help please. I don't know how I can position "remove" here is a part of the script:

species = input("Bacteria species ? : ")
TypeSeq= input ("fna ? or faa ? :")   

species = input("Bacteria species ? : ")
TypeSeq= input ("fna  ? ou faa  ?")   

if data["#Organism/Name"].str.contains(species, case = False).any():

    print(data.loc[data["#Organism/Name"].str.contains(species, case = False)]['Status'].value_counts())  
    FTP_list = data.loc[data["#Organism/Name"].str.contains(species, case = False)]["FTP Path"].values

if  TypeSeq == "faa" :

    if not os.path.exists(species):
        os.makedirs(species)

    for url in FTP_list:
        try : 
            parts = urllib.parse.urlparse(url)
            parts.path
            posixpath.basename(parts.path)
            suffix = "_protein.faa.gz"
            prefix = posixpath.basename(parts.path) 
            print(prefix+suffix)

            path = posixpath.join(parts.path, prefix+suffix)
            ret = parts._replace(path=path) 

            sequence = wget.download(urllib.parse.urlunparse(ret), out=species)
        except :
            print ("")


python


pandas

• 50 views



Source link