In [1]:
import subprocess
import os

path = './Bending_failure'
files = os.listdir(path)
if 'png' not in files:
    os.makedirs(path+'/png')
dest_path = path+'/png/'
for file in files:
    name_parts = file.split('.')
    if name_parts[-1]=='svg':
        orig = path+'/'+file
        dest = dest_path+name_parts[0]+'.png'
        cmd = 'rsvg-convert {} > {}'.format(orig,dest)
        subprocess.call(cmd,shell=True)
cmd = 'convert -delay 2 -loop 0 {}*.png {}animation.gif'.format(dest_path,dest_path)
subprocess.call(cmd,shell=True)
cmd = ('convert {}animation.gif \( +clone -set delay 200 \) '
       '+swap +delete  {}animation_with_pause.gif'.format(dest_path,dest_path))
subprocess.call(cmd,shell=True)


Out[1]:
0