How do I delete macro(s) from several hundred .odt documents (some are converted .doc documents)?

LO ver

If you are a fan of python, then the following script will rename your files to oldname-new.ods and strip Basic directory from the file, which gets rid of the scripts. It will however not check if you actually do use the scripts, so you better have a backup of the original files until you are sure all the files work correctly. To run it type to command line C:\Python2.7\python.exe *.ods when in correct directory. Also you would have to install python :slight_smile:


import glob, os, sys, zipfile

for pattern in sys.argv[1:]:
    for filepath in glob.glob(pattern):
        dirname, basename = os.path.split(filepath)
        root, ext = os.path.splitext(basename)
        newname = '%s-new%s' % (root, ext)
        outpath = os.path.join(dirname, newname)
        zin = zipfile.ZipFile (filepath, 'r')
        zout = zipfile.ZipFile (outpath, 'w')
        for item in zin.infolist():
            if item.filename == 'mimetype':
        for item in zin.infolist():
            if item.filename != 'mimetype' and item.filename[:6] != 'Basic/':

Credits for being helpful to and

Oh, and if using *.ods should create a too long command line, then put it inside quotes, “*.ods”, then glob will take care of it.