Shadow14l 0 Light Poster

I am using this function to download files:

def download(url):
    urllib.urlretrieve(url, url.split("/")[-1])

I am downloading files from a site, but I don't know the EXACT filename... All I know is the id for them...

Example:
download("http://site.com/files/489411/")

When i am to do that, it automatically resolves the appropriate filename and it will download it to my current directory.

It could be "Magics.ext", but I don't know that, all I know is that it (should be) is the last modified file.

=================================================

I need a function that takes nothing and returns the last modified filename for me. It does NOT have to return the directory information with it as well (ex. C:\\shadow\z\d\file.ext).

=================================================

I found a way how to do what I needed!

Here it is, for people with same problem:

import os

def getlatestfile():
    files = os.popen (r"dir /od /b *.*").read ().splitlines ()
    # dir /od /a-d /b # to avoid directories
    return files[-1]
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.