Rabu, 15 Februari 2012

Python - Directory Folder Scanner

My old Python script. I created this script to list all files in directory folders. It work similar to 'ls' command in Linux.

#!/usr/bin/python

# kuntoaji.blogspot.com

from os import walk
from sys import argv

def scanning(dir):
        for rootdir, dirs, files in walk(dir):
                for file in files:
                        print rootdir+"/"+file

if __name__ == "__main__":
        if len(argv) != 2:
                print "Usage: python dirscanner.py <YOUR_DIR>"
                exit()
        dir_name = argv[1]
        scanning(dir_name)

Artikel Terkait

Tidak ada komentar:

Posting Komentar

Related Posts Plugin for WordPress, Blogger...