Created
July 6, 2017 06:00
-
-
Save erinxocon/acb86453685437e72190d30264415543 to your computer and use it in GitHub Desktop.
A small directory walker that uses delegator.py to clean up some binary files
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
import os | |
import delegator | |
rootdir = '.' | |
for dirName, subdirlist, fileList in os.walk(rootdir): | |
print('Found Directory: {0}'.format(dirName)) | |
for name in fileList: | |
if name.lower().endswith('.job'): | |
file_name = '{0}/{1}'.format(dirName, name) | |
print('\tFile Found: {0}'.format(name)) | |
c = delegator.run('strings {0}'.format(file_name)) | |
with open(file_name.replace('.JOB', '.txt'), 'w') as out_file: | |
out_file.write(c.out) | |
print (c.out) | |
d = delegator.run('rm {0}'.format(file_name)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesn't check for correct paths or assemble correct paths using os.path(). It operates on a local basis only, be careful or the rm could remove unintended files! Thanks to @kennethreitz for delegator.py for easy use of the gnu utility strings!