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

This program can help convert source code written in Unix into a format that can easily be read under Windows.

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

def file_work(path):
    data = file(path).read()
    os.remove(path)
    file(path, 'w').write(data)

def dir_work(path):
    dirlist = os.listdir(path)
    for name in dirlist:
        full_path = os.path.join(path, name)
        if os.path.isdir(full_path):
            dir_work(full_path)
        elif os.path.isfile(full_path):
            file_work(full_path)

try:
    path = sys.argv[1]
    dir_work(path)
    print 'Done.'
except:
    name = os.path.basename(sys.argv[0])
    print name[:name.rfind('.')], '<directory>'

Yep, this is another command line program. The same *.tar.gz file that was being extracted had a bunch of text that was difficult to read. This program takes care of that (including all the sub-directories. Again, this isn't perfect for people who want more controls, but this program can get the job done rather well.