Welcome, guest | Sign In | My Account | Store | Cart

This program is slightly simpler that the first version.

Python, 20 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import os, sys

def main():
    try:
        search(' '.join(sys.argv[1:]))
        print 'Done.'
    except:
        print os.path.basename(sys.argv[0]), '<directory>'

def search(path):
    for name in os.listdir(path):
        path_name = os.path.join(path, name)
        if os.path.isdir(path_name):
            search(path_name)
        elif os.path.isfile(path_name):
            data = file(path_name).read()
            file(path_name, 'w').write(data)

if __name__ == '__main__':
    main()

This program is useful after unpacking a file with nothing but Unix text files in it. The files cannot be easily read in windows, and that is the problem that this program can fix.