diff --git a/src/calibre/ebooks/html.py b/src/calibre/ebooks/html.py
index c1ca9b8544..a7883ed763 100644
--- a/src/calibre/ebooks/html.py
+++ b/src/calibre/ebooks/html.py
@@ -1005,7 +1005,10 @@ def merge_metadata(htmlfile, opf, opts):
mi.cover = os.path.abspath(cover)
if not mi.title:
- mi.title = os.path.splitext(os.path.basename(htmlfile))[0]
+ if htmlfile:
+ mi.title = os.path.splitext(os.path.basename(htmlfile))[0]
+ else:
+ mi.title = _('Unknown')
if not mi.authors:
mi.authors = [_('Unknown')]
return mi