File Management Python scripts - Top 4 Download

File Management Python script downloads

A Python script to test download mirrors

The concept of the script is straightforward: read the mirrors page from RedHat's web site, make a list of all the mirrors, test how long it takes to download from each, and present a sorted list of the results.The first task, reading and parsing the RedHat mirrors list, is handled with ...
Python

Progress bar class

Here is a little class that lets you present percent complete information in the form of a progress bar using the '#' character to represent completed portions, space to represent incomplete portions, and the actual percent done (rounded to integer) displayed in the middle:[############# 33% >   [##;             & nbsp;            ] When you initialize the class, ...
Python

Parsing out EDI messages

A parser I designed to work with HIPAA EDI files. It reads in files and spits out the individual segments without terminators.Requires Python 2.3 or greater. (Use can probably use Python 2.2 with from __future__ import generators at the top...)This parser is currently in use to work with 150-200MB of EDI ...
Python

Recursive directory listing in HTML

This script contains a function that walks a directory path, listing the files and directories in HTML format. It can sometimes be handy to get a look at an entire directory tree, and HTML is a good way to display it. This script goes through the directory tree using os.path.walk in ...
Python

Curses File Manager

Curses File Manager is a curses based filemanager loosely resembling emacs dired mode. ...
Python

Cross Platform Excel Parsing With Xlrd

This script easily extract data from microsoft excel files using this wrapper class for xlrd. The class allows you to create a generator which returns excel data one row at a time as either a list or dictionary. This script is very useful for easily pulling in a variety of excel files without ...
Python

File Unzip

File Unzip is a Python class to extract zip files. It's also written for easy use as a standalone script from the commandline. While there are many ways to add files to a zip archive via python, I have been unable to locate a good solution of extracting those same files ...
Python

Display an Image from a specified file

This script reads an image file from the filename specified as the first parameter on the command line and displays it on screen. It uses the PIL module so that it can load almost any image file type supported by that module and uses Tkinter to display the image on a ...
Python

FSlint

FSlint is a utility to find and clean various forms of lint on a filesystem. One form of lint it finds for example is duplicate files. It has both GUI and command line modes. ...
Python

Dupinator

Point this script at a folder or several folders and it will find and delete all duplicate files within the folders, leaving behind the first file found of any set of duplicates. It is designed to handle hundreds of thousands of files of any size at a time and to do ...
Python

Directory Iterator

This script is an iterator that can be used to walk through directories.This class is intended to provide an iterator version of the os.listdir function. The interesting property of the iterator is that you can control if you want a deep iteration of directories with the 'deep' member.After having returned the path of ...
Python

Decorator

This script defines a "decorator" that, rather than decorating the function, calls it, passing it a file object that it had opened as the first argument.Of course, it makes sure to close the file upon the function's return (or nonreturn) with a try...finally block. One can use this decorator to get ...
Python

File Extractor

This program is meant to be used to extract *.BMP and *.JPG files from one file that has one or more of these image files stored inside of it. Corruption of the image file is verified manually after the file has been extracted.This program was designed for use with a deleted-file ...
Python

Filetail

This script is a module that allows for reading lines from a continuously-growing file (such as a system log).It handles log files that get rotated/trucated out from under us.This is useful for writing all sorts of log-monitoring scripts. As given, it only provides a line-by-line interface (perfectly reasonable if all you're doing ...
Python

A simple non recursive directory walker

This script is an equivalent of os.path.walk(), but without callback function. A simple directory walker, without the burden of creating a callback for os.path.walk().This is also usefull for incremental directory walking (where you want to scan remaining directories in subsequent calls). ...
Python

Python replacement for java util Properties

This script provides a quick and easy way to process Java properties files using pure Python. Of course, Jython can always be used, but in situations where Jython cannot be used, this recipe provides a sure-fire drop-in replacement.The Properties class is modelled to duplicate the behaviour of the original as closely ...
Python

C like iostream syntax in Python

This script represents a very simple proof-of-concept of an ostreams-like interface wrapping around file-like objects, included a demonstration of manipulators.Although theation of treams model does not make it necessary, it is quite easy to make a wrapper around file-like objects that behaves like the C ostreams'  insertion operator (e.g., cout Although ...
Python

Iterating through large file like objects

This function provides a simple iterator for the lines of a file-like object. (It also provides a flag for removing/retaining trailing newlines.) I ran into the problem a number of times that I wanted to read-in a very large file-like object (say a GB or two) line by line. This is ...
Python

Counting pages of PDF documents on Mac OS X

Given that PDF is a "native" data format on Mac OS X, it is very easy to get access to some properties of such documents. One is the number of pages. Using Python the necessary code to do this is only about four lines, plus some import and command-line plumbing, etc.This ...
Python

Flexible directory walking

This function walks a directory tree starting at a specified root folder, and returns a list of all of the files (and optionally folders) that match our pattern(s).The standard match our tree function os.path.walk can be confusing, and is difficult to customize. It can also be slow. Here's an alternative that ...
Python