Categories
Uncategorized

Simple File Lists – python

How to make quick directory lists in python. All of these will use listdir in the os module. so we need to import it first Now we want to list all the files in a directory called my_folder. But the trick is that we only want the text files. Another thing we can do is […]

Categories
Uncategorized

Dot Graph for Directory – Python

How to create a dot graph for a directory. The Problem I wrote the dir2dot( ) python function in my previous post…but it has one massive mistake. If we have items in different folders that have the same name, the function gets all confused and freaks out. For example, if we have the following directory: […]

Categories
Uncategorized

Renaming Files in Directory – Python

This script will look for all the files in a directory that end with the extension .txt and change them all to .html using the rename function in the os module. The script was written for a directory with the following structure Also, I am sure there is a more eficient way of getting the […]

Categories
Uncategorized

Listing files in a bunch of folders – Python

We have a whole bunch of files and we want to crawl through them and list them. Crawling through folders This can be done using the walk() function in the os python module. You can read all about it here, but you basically end up with a tuple, containing the directory path, the directory names, […]