From 312617e06910d107c1ee520ca45f0ea7e575951a Mon Sep 17 00:00:00 2001 From: Nicolas Morey-Chaisemartin Date: Tue, 19 Jun 2018 17:02:23 +0200 Subject: [PATCH 1/3] * cbr2cbz.py: Support filename with whitespace Signed-off-by: Nicolas Morey-Chaisemartin --- README.md | 4 ++-- cbr2cbz.py | 3 +-- cbrfolder2cbz.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 724e1c2..08db88d 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ Requirements Usage ----- -To convert a single CBR file use this (the script can't handle filenames with spaces): +To convert a single CBR file use this: -``./cbr2cbz.py `` +``./cbr2cbz.py `` To convert an entire directory with CBR files in it use: diff --git a/cbr2cbz.py b/cbr2cbz.py index fa76f1b..e4c73ab 100755 --- a/cbr2cbz.py +++ b/cbr2cbz.py @@ -28,7 +28,7 @@ def uncompress(filename, directory): def compress (directory, zip_filename): ZIP="zip" directory=directory+"/*" - command=" ".join([ZIP, zip_filename, directory ]) + command=" ".join([ZIP, "\""+zip_filename+"\"", directory ]) execute (command) def get_filename_without_extension(filename): @@ -58,7 +58,6 @@ compress(temp_dir, cbz_filename) - def extract (cbr_filename, dir_name): pass diff --git a/cbrfolder2cbz.py b/cbrfolder2cbz.py index 5fbe81d..364e028 100755 --- a/cbrfolder2cbz.py +++ b/cbrfolder2cbz.py @@ -19,7 +19,7 @@ def print_usage(): def convert(filename): CONVERT="./cbr2cbz.py" - command=" ".join([CONVERT, filename]) + command=" ".join([CONVERT, "\""+filename+"\""]) execute(command) if len(sys.argv)!=2: From c4b29aeb4b068930dba0b0b822faab6fae2fc917 Mon Sep 17 00:00:00 2001 From: Nicolas Morey-Chaisemartin Date: Tue, 19 Jun 2018 17:04:12 +0200 Subject: [PATCH 2/3] * cbrfolder2cbz.py: Support converting multiple directories at once Signed-off-by: Nicolas Morey-Chaisemartin --- cbrfolder2cbz.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cbrfolder2cbz.py b/cbrfolder2cbz.py index 364e028..f36be92 100755 --- a/cbrfolder2cbz.py +++ b/cbrfolder2cbz.py @@ -13,7 +13,7 @@ def print_err(message): def print_usage(): usage="cbr2cbz A script utility to convert a directory with CBR files into CBZ files" - usage+="\n\t Usage: cbr2cbz " + usage+="\n\t Usage: cbr2cbz [ ...]" usage+="\n\t\n\t (Please don't use non-free formats like RAR/CBR)" print_err(usage) @@ -22,16 +22,17 @@ def convert(filename): command=" ".join([CONVERT, "\""+filename+"\""]) execute(command) -if len(sys.argv)!=2: +if len(sys.argv)<2: print_usage(); sys.exit(-1) +sys.argv.pop(0) - -directory=os.path.abspath(sys.argv[1]) - -for f in os.listdir(directory): - filename_with_path=os.path.join(directory, f) - print(filename_with_path) - convert(filename_with_path) \ No newline at end of file +for dir in sys.argv: + print dir + directory=os.path.abspath(dir) + for f in os.listdir(directory): + filename_with_path=os.path.join(directory, f) + print(filename_with_path) + convert(filename_with_path) From ea1cc1a43e82f16312193e4ab55dcd54b1af079d Mon Sep 17 00:00:00 2001 From: Nicolas Morey-Chaisemartin Date: Tue, 19 Jun 2018 17:02:23 +0200 Subject: [PATCH 3/3] * cbr2cbz.py: Remove temporary folder after conversion Signed-off-by: Nicolas Morey-Chaisemartin --- cbr2cbz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cbr2cbz.py b/cbr2cbz.py index e4c73ab..ffb4b7e 100755 --- a/cbr2cbz.py +++ b/cbr2cbz.py @@ -54,7 +54,7 @@ uncompress(sys.argv[1], temp_dir) #Compress images and put them into a CBZ/ZIP compress(temp_dir, cbz_filename) - +execute("".join(["rm -Rf ", temp_dir]))