Create necessary directories for --print-to-file

Closes #2721
This commit is contained in:
pukkandan 2022-02-18 17:51:43 +05:30
parent 3aa915400d
commit 8d93e69d67
No known key found for this signature in database
GPG Key ID: 7EEE9E1E817D0A39

View File

@ -2735,6 +2735,7 @@ def format_tmpl(tmpl):
filename = self.evaluate_outtmpl(file_tmpl, info_dict)
tmpl = format_tmpl(tmpl)
self.to_screen(f'[info] Writing {tmpl!r} to: {filename}')
if self._ensure_dir_exists(filename):
with io.open(filename, 'a', encoding='utf-8') as f:
f.write(self.evaluate_outtmpl(tmpl, info_copy) + '\n')