'error generating font in FontForge script

I am making a script to convert woff fonts to otf the problem is that when generating the font it says "error saving" can anybodty help? this is the script:

import fontforge as f
import os
path_of_the_directory = 'C:/Users/????/woff - Copy'
ext = ('.woff','.woff2')
for files in os.listdir(path_of_the_directory):
 if files.endswith(ext):
  MyFile = path_of_the_directory + "/" + files
  f.open(MyFile)
  MyName = MyFile.replace('woff2', 'otf')
  MyName = MyFile.replace('woff', 'otf')
  f.font.generate(MyName)
 else:
  continue

also can how do you close the font after generating?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source