diff --git a/jrnl/EncryptedJournal.py b/jrnl/EncryptedJournal.py index 2a6df460..6121f304 100644 --- a/jrnl/EncryptedJournal.py +++ b/jrnl/EncryptedJournal.py @@ -40,8 +40,11 @@ class EncryptedJournal(Journal): """Opens the journal file defined in the config and parses it into a list of Entries. Entries have the form (date, title, body).""" filename = filename or self.config["journal"] - + dirname = os.path.dirname(filename) if not os.path.exists(filename): + if not os.path.isdir(dirname): + print(f"[Directory {dirname} created]") + os.mkdir(dirname) self.create_file(filename) self.password = util.create_password(self.name) print( diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 23fa80a0..45596192 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -74,8 +74,11 @@ class Journal: """Opens the journal file defined in the config and parses it into a list of Entries. Entries have the form (date, title, body).""" filename = filename or self.config["journal"] - + dirname = os.path.dirname(filename) if not os.path.exists(filename): + if not os.path.isdir(dirname): + print(f"[Directory {dirname} created]") + os.mkdir(dirname) self.create_file(filename) print(f"[Journal '{self.name}' created at {filename}]", file=sys.stderr)