Posted in All Other Stuff

Listing Files In A Directory – Python

Here is the code for listing the files in a directory using Python. In case you don’t know, Python is a great and easy-to-learn programming language. Go check out the main Python website.

import os
path=”C:\\somedirectory” # insert the path to the directory of interest
here
dirList=os.listdir(path)
for fname in dirList:
print fname

Credit for this code goes to this post

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s