<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def export_shell(file_index, to_dir):
 """ Export all shell commands from files in the file index into given directory """

    if not exists(to_dir):
        makedirs(to_dir)

    for _, file_data in file_index.files.items():
        export_from_file(file_data, to_dir)