2014-11-11 22:26:56 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
|
|
|
|
def execute(command):
|
|
|
|
os.system(command)
|
|
|
|
|
|
|
|
def print_err(message):
|
|
|
|
execute(">&2 echo \""+message+"\"")
|
|
|
|
|
|
|
|
def print_usage():
|
2014-11-11 22:41:58 +01:00
|
|
|
usage="cbr2cbz A script utility to convert a directory with CBR files into CBZ files"
|
2018-06-19 17:04:12 +02:00
|
|
|
usage+="\n\t Usage: cbr2cbz <directory> [<directory> <directory> ...]"
|
2014-11-11 22:26:56 +01:00
|
|
|
usage+="\n\t\n\t (Please don't use non-free formats like RAR/CBR)"
|
|
|
|
print_err(usage)
|
|
|
|
|
2014-11-11 22:41:58 +01:00
|
|
|
def convert(filename):
|
|
|
|
CONVERT="./cbr2cbz.py"
|
2018-06-19 17:02:23 +02:00
|
|
|
command=" ".join([CONVERT, "\""+filename+"\""])
|
2014-11-11 22:26:56 +01:00
|
|
|
execute(command)
|
|
|
|
|
2018-06-19 17:04:12 +02:00
|
|
|
if len(sys.argv)<2:
|
2014-11-11 22:26:56 +01:00
|
|
|
print_usage();
|
|
|
|
sys.exit(-1)
|
|
|
|
|
|
|
|
|
2018-06-19 17:04:12 +02:00
|
|
|
sys.argv.pop(0)
|
2014-11-11 22:26:56 +01:00
|
|
|
|
2018-06-19 17:04:12 +02:00
|
|
|
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)
|