<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def process_casefile(cls, workdir):
        '''generate code from case.json'''
        record = cls(None, workdir)
        obj = {}
        with open(os.path.join(workdir, 'frames', 'frames.json')) as f:
            obj = json.load(f)
        record.device_info = obj['device']
        record.frames = obj['frames']

        casedir = os.path.join(workdir, 'case')
        with open(os.path.join(casedir, 'case.json')) as f:
            record.case_draft = json.load(f)

        # remove old files
        for f in os.listdir(casedir):
            if f != 'case.json':
                os.remove(os.path.join(casedir, f))

        record.generate_script()