The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Remove A Key From Frontmatter In Python

TODO: Pull subtitle into page object

TODO: refine this to a better example:

code_start_default_section code_end_default_section

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Remove A Key From Frontmatter In Python

-- p

TODO: refine this to a better example:

-- code/
-- python3

#!/usr/bin/env python3

import frontmatter
import glob
import os

from os.path import isfile

def clear_output_dir(output_dir):
    files_to_delete = [
        file for file in glob.glob(f"{output_dir}/*.txt" )
        if isfile(file)

    for file_to_delete in files_to_delete:

def make_files(input_dir, output_dir):
    files = [
        file for file in glob.glob(f"{input_dir}/*.txt")
        if isfile(file)

    for file in files:
        post = frontmatter.load(file) 

        if 'created' in post:

            output_file = file.replace(input_dir, output_dir)
            with open(output_file, 'w') as _out:
                frontmatter.dump(post, output_file)

            # print(post['created'])

if __name__ == "__main__":
    input_dir  = '/Users/alans/workshop/site_content_ksuid_migration_data/04_status_updates'
    output_dir = '/Users/alans/workshop/site_content_ksuid_migration_data/05_clean_frontmatter'

    make_files(input_dir, output_dir)

-- /code

-- categories
-- Python

-- metadata
-- date: 2021-11-06 21:50:38
-- id: 20eogn4t
-- status: draft
-- type: post
-- SCRUBBED_NEO: false
-- site: aws