OK I think I found my error, here is what I did: flags = set([file for file in glob.glob('flag-*.svg')]) def call(cmd): subprocess.call([cmd], shell=True) for flag in flags: name = flag[:-4] out = name+'.png' call('svg2png --width=17 --height=12 %s %s' \ % (flag, out)) Is this better?