Created
August 25, 2013 04:18
-
-
Save attomos/6331976 to your computer and use it in GitHub Desktop.
Prepend files in current directory with specified text.
I used this Gist to prepend my imported blog (markdown files) to serve with Jekyll.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # encoding: utf-8 | |
| import os | |
| text_to_prepend = '# encoding: utf-8' | |
| for root, dirs, files in os.walk('./'): | |
| for f in files: | |
| if f != 'prepend.py': | |
| with file(f, 'r') as original: | |
| data = original.read() | |
| with file(f, 'w') as modified: | |
| modified.write(text_to_prepend + '\n' + data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment