-4

I am using your ftputil within a python script to get last modification/creation date of files in directory and I am having few problems and wondered if you could help.

      host.stat_cache.resize(200000)
 recursive = host.walk(directory, topdown=True, onerror=None)
  for root,dirs,files in recursive:
       for name in files:
            #mctime = host.stat(name).mtime
            print name

The above outputs a listing of all files in the directory

      host.stat_cache.resize(200000)
 recursive = host.walk(directory, topdown=True, onerror=None)
 for root,dirs,files in recursive:
       for name in files:
          if host.path.isfile("name"):
             mtime1 = host.stat("name")
             mtime2 = host.stat("name").mtime
             #if crtime < now -30 * 86400:
             #print name + " Was Created " + " " + crtime + " " + mtime
             print name + " Was Created " + " " + " " + mtime1 + " " + mtime2

Above produces no output

VisioN
  • 143,310
  • 32
  • 282
  • 281
Echo
  • 1
  • 2
  • 1
    Who is "your" referring to here? Also from looking at the code, you could get no output if `files` or `recursive` is empty or if the `isfile` check fails for each file. Try adding a `print files` and `print recursive` before the loop. – Daenyth Aug 29 '12 at 15:34
  • recursive = host.walk(directory, topdown=True, onerror=None) for root,dirs,files in recursive: for name in files: #mctime = host.stat(name).mtime print name – Echo Aug 29 '12 at 16:05
  • above produces a list of files so recursive and files contain something – Echo Aug 29 '12 at 16:06

1 Answers1

1

You've put name in quotes. So Python will always be checking for the literal filename "name", which presumably doesn't exist. You mean:

      if host.path.isfile(name):
         mtime1 = host.stat(name)
         mtime2 = host.stat(name).mtime
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895