Skip to content

Instantly share code, notes, and snippets.

@yono
Created October 24, 2010 06:04
Show Gist options
  • Save yono/643185 to your computer and use it in GitHub Desktop.
Save yono/643185 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import commands
import os
import re
import sys
dirnum= sys.argv[1]
os.chdir('memo%s' % (dirnum))
files = commands.getoutput('ls -1').splitlines()
num = 1
for afile in files:
afile_read = open(afile).read().splitlines()
first = True
memo = []
for line in afile_read:
if first:
memo.append(re.sub('^', '* ', line))
first = False
if line.startswith('・') or line.startswith(' *'):
memo.append(line.replace('・','- ').replace(' *','- '))
elif line.startswith(' o'):
memo.append(line.replace(' o',' -'))
elif line.startswith(' +'):
memo.append(line.replace(' +',' -'))
else:
memo.append(line)
print afile, '%s-%d.org' % (dirnum, num)
newfile = open('%s-%d.org' % (dirnum, num), 'w')
newfile.write('\n'.join(memo))
num += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment