# Convert a bunch of CBF files into EDF format

This simple tutorial explains how to convert a bunch of CBF files to EDF files.

    [1]:

    import glob
    files = glob.glob("*.cbf")
    files.sort()
    print("Number of files: %s" % len(files))

    Number of files: 18

    [2]:

    dest_format = "edf"
    dest_dir = "edf_format"

    [3]:

    import fabio, os
    if not os.path.exists(dest_dir):
        os.makedirs(dest_dir)

    [4]:

    %%time
    for onefile in files:
        dst_name = os.path.join(dest_dir, os.path.splitext(onefile)[0] + "." + dest_format)
        fabio.open(onefile).convert(dest_format).save(dst_name)

    CPU times: user 476 ms, sys: 576 ms, total: 1.05 s
    Wall time: 1.06 s

    [5]:

    print("The overall speed is %.1f frame/second"%(len(files)/5.64))

    The overall speed is 3.2 frame/second

## Conclusion

This simple tutorial explains how to perform simple file conversion. It is likely to be limited by the bandwidth available for the hard-drive of your computer or by the compression/decompression algorithm as it the case here for CBF decompression.

    [ ]: