sync databse table based on current directory data without losign previous values

Michael Ross gmx at
Wed Mar 6 15:04:26 CET 2013

On Wed, 06 Mar 2013 12:52:00 +0100, Mark Lawrence  
<breamoreboy at> wrote:

> On 06/03/2013 07:45, Νίκος Γκρ33κ wrote:
>> I'am using this snipper to read a current directory and insert all  
>> filenames into a databse and then display them.
>> But what happens when files are get removed form the directory?
>> The inserted records into databse remain.
>> How can i update  the databse to only contain the existing filenames  
>> without losing the previous stored data?
>> Here is what i ahve so far:
>> ==================================
>> path = "/home/nikos/public_html/data/files/"
>> #read the containing folder and insert new filenames
>> for result in os.walk(path):
> You were told yesterday at least twice that os.walk returns a tuple but  
> you still insist on refusing to take any notice of our replies when it  
> suits you, preferring instead to waste everbody's time with these  
> questions.  Or are you trying to get into the Guinness Book of World  
> Records for the laziest bastard on the planet?

Hold on a sec ...

He has

for result in os.walk(path):
	for filename in result[2]:

So he *did* take notice of that.

Expectation is to iterate through a tuple like this:

for dirpath, dirnames, filenames in os.walk(path):

More information about the Python-list mailing list