1

I would like to know how to get a list of filenames (.jpg image files) that are stored on a server.

I am looking for code which stores all the filenames (with their extension) in an Excel table or in the CSV format.

Any tips will be very helpful.

Michael Celey
  • 12,645
  • 6
  • 57
  • 62

1 Answers1

-2

It's pretty easy to get the filenames of all files stored in a certain folder, and you can easily write it in a file (in whatever format you want) :

import os
filenames = os.listdir('path to directory')
logFile = open('filenames.txt')
for name in filenames:
    logFile.write(filename)
logFile.close()

You must execute this code on your server, so make sure you can execute Python code on it.

Once that's done, you can retrieve it from your server using the urllib2 module : How do I download a file over HTTP using Python?

Community
  • 1
  • 1
halflings
  • 1,540
  • 1
  • 13
  • 34