-
Notifications
You must be signed in to change notification settings - Fork 0
Replaces text in all the files contain within a directory and its child directories. Implemented as a "programming challenge" from a prospective employer.
License
jburwell/file-text-replacement
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Introduction ------------ file-text-replacement is a Python script that performs whole word replacement recursively over a directory tree. In order to ensure the integrity of its backup and log files across multiple execution runs, the script creates a unique process id which is used in all log file and backup file names. This process id also provides traceability across execution runs to support diagnostic activities. The process id is created from by concatenating the current two-digit month, two-digit day, four-digit year together with the current two-digit hour, two-digit minute, and two-digit second separated by a dash. N.B. All search operations performed by this utility are case sensitive License ------- file-text-replacement is licensed under the BSD license. Requirements ------------ * Python 2.5 or 2.6 While this script should operate on Linux-based and Windows-based operating systems, it has only been tested on Mac OS X 10.5. Operation --------- The script is executed using the following command line template: python replacer/replacer.py [options] search_path search_text replacement_text The script requires the following arguments: * A search path which serves as the root of the scripts search and replace operations * The search text to be replaced * The replacement text for the search text The script also supports the following commmand line switches: * -b: Create a backup of each file * -o: Log to which to capture which files were modified * -v: Output verbose diagnostic information to the log Each execution of the script yields a log file named <process id>-replacement.log in the execution directory. Backup files are named <file name>.<process id>.rbak and are placed in the same directory as the original. The script does _not_ process files with the .rbak file extension. Note ---- This script was written to complete a programming challenge for a prospective employer that was defined as follows: a. The Program will allow these arguments: i. A path to a directory of files. ii. A original text or pattern which will replace the original one if found in the files (as many times as it was found). iii. A new text or pattern which will replace the original one if found in the file (as many times as it was found). b. Optionally, the class might also get an argument for a path to a file for outputting a list of which files were modified. c. Add comments to your class. d. Extra points if you back up the original file before replacing the text. e. Extra points if you implement some simple and creative logging (start time, errors, end time, pattern found and where, etc)
About
Replaces text in all the files contain within a directory and its child directories. Implemented as a "programming challenge" from a prospective employer.
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published