Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'attribute': 0.07; 'python': 0.08; 'question?': 0.09; 'subject:Accessing': 0.09; 'subject:files': 0.09; 'am,': 0.12; '(note': 0.16; 'result)': 0.16; 'cc:addr:python-list': 0.16; 'syntax': 0.16; 'wrote:': 0.18; 'modified': 0.18; 'programming': 0.20; 'cheers,': 0.20; 'cc:no real name:2**0': 0.21; 'trying': 0.21; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.26; 'language.': 0.28; "i'm": 0.28; 'script': 0.28; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.29; '22,': 0.30; 'either.': 0.30; 'recursively': 0.30; 'chris': 0.30; "didn't": 0.30; 'url:library': 0.31; 'thu,': 0.32; "i've": 0.32; 'subject:time': 0.32; 'file': 0.34; 'url:python': 0.35; 'post': 0.36; 'received:209.85.214': 0.36; 'received:google.com': 0.37; 'similar': 0.37; 'using': 0.37; 'received:209.85': 0.38; 'subject:last': 0.38; 'url:org': 0.39; 'received:209': 0.39; 'simple': 0.61; 'reply': 0.64; 'forum': 0.64; 'saw': 0.66; 'due': 0.66; 'topic,': 0.80; 'sender:addr:chris': 0.84; 'url:join': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=ujTN6FA18mKw7D5oO7rgcryG16l0Pi+Cf3VqO88jjcQ=; b=QRFs7M0XaWwM9oEFQ62qeZu/sZCn08ntSLx5IecCKfDZfY9Hd8HbdUyltR9eCzbqFq vGPKdyoQcFeZIZmGQcHvtHD553H+8YahQodYhYUanMC/2e5e+YrFb6YexycKD1j7Yp7a zDyBmBUfPxARFpIeRa2OIz5UTTe+ifQWNkfk8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=ujTN6FA18mKw7D5oO7rgcryG16l0Pi+Cf3VqO88jjcQ=; b=jgBDI5vUDdzeC0R6yN8Xm1MO5W7GtrVB/yb0drtjCpJ9qZoPvGi+eXJ2DJJAEoiwvj I1SSVnMZK6N5qNjBhBwRwF1a6h09IgKLHJ8f7RTSNpIsu74cdoojGs7EtGVl4cT+jWKb lKPDYQ/w/R62Bot8lys67tmmsezyE0Oe4wSCw5yqn4jAvag7LRZ+XhaEOp/0or8/S/CL yw7VgAH39edE0ccRZr2hftw3KRZ/kIjf9PVnG/60hLHxcQg0uQlNHM8ySsbfOb1uU6nG f+t8rreBjIMbnE34axuF+w5mnODL7qzZcGf7+HLlhe4ffoKSyT3z5WcEZPbm0JMyr4rv DGCw== MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: <26215939.1574.1332416026298.JavaMail.geo-discussion-forums@ynlt17> References: <26215939.1574.1332416026298.JavaMail.geo-discussion-forums@ynlt17> Date: Thu, 22 Mar 2012 04:49:23 -0700 X-Google-Sender-Auth: HjsEnRumkV7C66t8e4ExDixRlQo Subject: Re: Accessing the files by last modified time From: Chris Rebert To: Sangeet Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQnK+Q98d75/rdxu0WJ/SMo1MZFQ9FHBVEm0TS3XvILeX136gy3WmSgTXBIFinnJwia+Dwoi Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1332416966 news.xs4all.nl 6955 [2001:888:2000:d::a6]:36184 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22016 On Thu, Mar 22, 2012 at 4:33 AM, Sangeet wrote: > Hi > > I am new to the python programming language. > > I've been trying to write a script that would access the last modified file in one of my directories. I'm using Win XP. > > I saw a similar topic, on the forum before, however the reply using (os.popen) didn't work out for me. I'm not sure whether it was due to syntax errors either. Recursively or non-recursively? Live monitoring or just one-time? What was the forum post in question? In the simple case, you just need to stitch together these functions: http://docs.python.org/library/os.html#os.stat (note the .st_mtime attribute of the result) http://docs.python.org/library/os.path.html#os.path.join with one of these functions: http://docs.python.org/library/os.html#os.listdir http://docs.python.org/library/os.html#os.walk Cheers, Chris