From f33ed84cd3bbd9c35b6e45cfa4a4d6597806305e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 23 Dec 2011 08:31:03 +0530 Subject: [PATCH] Allow passing multiple filenames as command line arguments to calibre to add multiple books. Fixes #907968 (Right click open with) --- src/calibre/gui2/main.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 539110fb92..3c0227df26 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -143,12 +143,11 @@ class GuiRunner(QObject): add_filesystem_book = partial(main.iactions['Add Books'].add_filesystem_book, allow_device=False) sys.excepthook = main.unhandled_exception if len(self.args) > 1: - p = os.path.abspath(self.args[1]) - if os.path.isdir(p): - prints('Ignoring directory passed as command line argument:', - self.args[1]) - else: - add_filesystem_book(p) + files = [os.path.abspath(p) for p in self.args[1:] if not + os.path.isdir(p)] + if len(files) < len(sys.argv[1:]): + prints('Ignoring directories passed as command line arguments') + add_filesystem_book(files) self.app.file_event_hook = add_filesystem_book self.main = main