def main(opts):
    "Main function"
    if not [os.path.isdir(x) for x in vars(opts)]:
        raise IOError("No such directory")
    # add slash at the end of directory
    slashIt = lambda x: x if x.endswith("/") else x + "/"
    path = slashIt(opts.path)
    pathConverted = slashIt(opts.pathConverted)
    pathManual = slashIt(opts.pathManual)

    manualReplacments = []
    fileNames = []
    for name in FileReader.getFileNames(path):
        # extracts file name from path
        fileName = FileReader.getFileName(name)
        # get file lines
        fileLines = FileReader.readFile(name)
        templateConverter = TemplateConverter(fileLines, name)
        # get converted lines
        convertedLines = templateConverter.getFileLines()
        # add lines that are inconvertible to the list
        manualReplacments += templateConverter.irreversibleDataList
        fileNames += [x.fileName for x in templateConverter.irreversibleDataList]
        fileName = fileName + ".tmpl"
        # save jinja2 template
        FileWriter.writeToFile(pathConverted + fileName, convertedLines)
    # save info about inconvertible template
    print(str(len(list(set(
        fileNames)))) + " file(s) need manual conversion. More information can be found in:\n" +
          pathManual + "manualConversions.txt")
    FileWriter.writeToFile(pathManual + "manualConversions.txt", FileWriter.convertToString(manualReplacments))