# This little script is for personal use.
# Creates ocp files and moves them to the
# parent directory.
# 2004. Javier Bezos. Public domain.

import glob, os

def mtptoocp(i):
    os.system('python ..\\Tools\\mtp2ocp.py %s' % i[:-4])
    print ' ->  done'
    try:    os.remove('..\\%s.ocp' % i[:-4])
    except: pass
    os.rename(i[:-4] + '.ocp', '..\\%s.ocp' % i[:-4])
#end

for i in glob.glob('*.mtp'):
    print 'Creating ', i,
    if os.path.exists('..\\%s.ocp' % i[:-4]):
        if os.path.getmtime(i) > os.path.getmtime('..\\%s.ocp' % i[:-4]):
            mtptoocp(i)
        else:
            print i, ' ->  skipped'
        #end
    else:
        mtptoocp(i)
    #end