File Management Python scripts - Top 4 Download

File Management Python script downloads

Resuming download of a file

This script shows how to resume downloading of a file that has been partially downloaded from a web server. It's been tested with Apache 1.3.x, but should work with any web server that understands the "range" header.This script uses the extra header - "Range" to let the web server know that ...
Python

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

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

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

Extracting tar gz files in Windows

This script is meant to be used as a commmand line *.tar.gz file extractor. If it fails, then a usage note is given. It may be small, but it can be very useful for some people. Theuseful fofor which this program was written is that Windows does not come with a *.tar.gz ...
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

Cache file contents to speed access

This class caches the contents of a set of files and avoids reading files repeatedly from disk by holding onto the contents of each file as a list of strings.Some tasks require reading from a set of files in a random manner. Opening and reading files is a time consuming operation ...
Python

RoadRunner

This recipe allows you to update desired files in a directory tree. It needs to be run from the shell. Once you run it, it will ask you for: a) the "string" you want to insert in the file b) the extension of the files to update e.g: .html c) a ...
Python

Safely morph a file in place

This script contains a class that enables a client to securely update an existing file, including the ability to make an automated backup version.This code encapsulates the method to safely update files in-place, by first writing to a temporary file and finally renaming the new temporary file to the old filename. This ...
Python

Versioning file names

This script has the following action: if the specified file exists, it is versioned by appending to the extension a three-digit number, starting with "000".It's pomp;quot;0ake backups of files before you mangle them. A standard way of doing so is to appending to the extension an incremented number. The optional second ...
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

Extracting Windows file versions

This is my attempt at extracting the file version information from .dll, .exe, .ocx files etc. on Windows 2000 (should work with others, but I haven't tested it), without resorting to using extensions (i.e. dll functions). Put the code in a file in your PYTHONPATH (such as 'verchecker.py') and say 'from verchecker ...
Python

Swap one file extension

This script will swap extensions on all files in the specified directory, and all of its subdirectories, and all of their subdirectories, etc. This is useful for changing the extensions of a whole batch of files in a folder structure, e.g. a web site. You can also use it for correcting ...
Python

Helpful 5 liner version of os makedirs

This script contains a function that creates missing directories for a given path and returns a normalized absolute version of the path.If the given path already exists in the filesystem the filesystem is not modified.Otherwise makepath creates directories along the given path using the dirname() of the path. You may append a ...
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

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

Zip and Pickle

This module saves and reloads compressed representations of generic Python objects to and from the disk. ...
Python

Where file search utility

This utility searches all the paths in a semi-colon delimited environment variable list for files matching a given filespec. By default, PATH is used for the enviroment. For example, on my >computerC:where note*.exeC:WINNTsystem32otepad.exeC:WINNTNOTEPAD.EXEThis is useful for finding which executable file will be loaded by default. The optional Environment variable is handy ...
Python

Clean up a directory tree

This script can be used to clean up a directory tree irrespective of whether the directory tree contains non-empty directories. As long as the user has permission to remove the files, this will work.There is no files, thor cleaning a non-empty directory tree in python os module. os.removedirs() cannot be used to ...
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