Imported frontmatter md has untitled as title

Operating system

Windows

Joplin version

2.13.8

Desktop version info

Joplin 2.13.8 (prod, win32)

Client ID:xxxxxxxxxx
Sync Version: 3
Profile Version: 44
Keychain Supported: Yes

Revision: 604dcbc

CodeMirror Line Numbers: 2.0.0
Csv Import: 1.0.1
Cursor Sync: 2.1.0
Enhanced Editing: 0.1.0
Enhancement: 1.2.1
Ez Table: 1.0.2
Favorites: 1.3.2
Freehand Drawing: 2.5.0
Insert Date: 1.0.1
MultiMarkdown Table Tools: 1.1.0
OCR: 0.3.2
Persistent Editor Layout: 2.2.0
Rich Markdown: 0.13.3
Search & Replace: 2.2.0
Table Formatter Plugin: 1.2.1

Sync target

File system

Editor

Markdown Editor

What issue do you have?

The md frontmatter import notes with "untitled" as the title. I tested with multiple files, with the same issue.

Here is the md file to test name is it as \

windows - Python recursively remove filesfolders in a directory, but not the parent directory or a specific folder - Stack Overflow.md

---
created: 2023-12-05T17:47:26 (UTC -06:00)
tags:
  - dev
source: https://stackoverflow.com/questions/36267807/python-recursively-remove-files-folders-in-a-directory-but-not-the-parent-direc
author: |-
  redjax
  6311 gold badge11 silver badge66 bronze badges
---

# windows - Python recursively remove files/folders in a directory, but not the parent directory or a specific folder - Stack Overflow

> ## Excerpt
> This type of question has been asked before, but I can't seem to get exactly what I want through the help I've found.

This question has an answer by user Iker, where the user gives code that does ...

---
This type of question has been asked before, but I can't seem to get exactly what I want through the help I've found.

[This question](https://stackoverflow.com/questions/185936/delete-folder-contents-in-python) has an [answer by user Iker](https://stackoverflow.com/a/1073382/3376264), where the user gives code that _does_ work exactly as intended: it removes all the files and directories from a folder, but not the parent folder itself.

I want to tweak this further by deleting all the files from a parent directory, but not the parent directory, and I want to exclude a folder within the directory.

The code I am using is:


I have tried adding an "If" statement after the "for" statement that basically says:

if files != keep

and I have a variable "keep" pointing to a folder in the parent file called "keep," so that this script will delete everything except the parent directory and the directory called "keep" within the parent. However, after adding that, the code does not work.

Here is the exact code I had, with the if statement that breaks the code:


I'm sure what I'm doing is very obvious, but it is not obvious to me, so any help will be appreciated.

Thanks!

**EDIT**: Based on Ben's answer below, here is the code that worked for me:


Screenshots

The obvious thing is that there is no title entry in the frontmatter. The import spec doesn't have it as an example but does imply that if a field is missing then it would be created as if a normal note was imported:

The importer will import the metadata corresponding to all of the above fields. Missing data will be filled in as if the note was just created. Extra fields will be ignored.

It doesn't look like this was ever an expected case though as I can't see any test files that omit the title key nor any test that checks for its omission.

This is what the Markdownload browser extension exports. Would not make sense it would use the filename if the title is missing?

That's what I was saying above:

The importer will import the metadata corresponding to all of the above fields. Missing data will be filled in as if the note was just created. Extra fields will be ignored.

However it seems a missing title tag isn't something that has ever been accounted for and isn't part of the tests.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.