File Management Python scripts - Top 4 Download

File Management Python script downloads

Rename subdirectories of a directory tree

I needed to write a sed/awk Python equivalent for walking into a directory tree and renaming certain subdirectories, while also looking into all xml files on the way and replacing/modifying certain strings in those files.It would be nicer if someone could suggest an enhanced re.sub(regex, replacement, subject) where I could replace ...
Python

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

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

Simple File Splitter Combiner module

This module can be used to split any file, text or binary to equal sized chunks. It can also combine the chunks back to recreate the original file.<s. It canOften we need to split big files into many chunks either for saving them to disks, uploading to a web-site or for ...
Python

Simple md5 sum utility

This script is a simple md5 hash utility for generating md5 checksums of files. <hash utilThis mainly useful for systems without an included "md5sum" utility, like OS-X and Win32. It shows just how useful the batteries included philosophy of Python can be, since it leverages the md5 module ...
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

Tree

The following program displays the directory structure of a specified path using ASCII characters. The program can optionally display files in addition to directories.This program functions similar to the windows 'tree' command. ...
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

Watching a directory tree on Unix

This script continuously monitors the paths and their subdirectories for changes. If any files or directories are modified, the callable 'func' is called with a list of the modified paths of both files and directories.'func' can return a Boolean value for rescanning; if it returns True, the directory tree will be ...
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

z directory

This script is a memory-based directory copier and paster. Pickled Directory objects will contain all data from a directory at path and can be saved in other locations.Once a Directory object has been created, pasting it to another location is ex has beenimple. ...
Python

Zip and Pickle

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