Skip to content

Commit

Permalink
add --no-overwrite flag
Browse files Browse the repository at this point in the history
When enabled, vcsi will skip processing files for which the output file already exists.

close #47
  • Loading branch information
amietn committed Jul 16, 2018
1 parent 8ae4030 commit d3d6117
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions vcsi/vcsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,9 +940,6 @@ def draw_metadata_helper():
def save_image(args, image, media_info, output_path):
"""Save the image to `output_path`
"""
if not output_path:
output_path = media_info.filename + "." + args.image_format

image = image.convert("RGB")
try:
image.save(output_path, optimize=True, quality=args.image_quality)
Expand Down Expand Up @@ -1341,6 +1338,12 @@ def main():
action="store_true",
help="Ignore any error encountered while processing files recursively and continue to the next file.",
dest="ignore_errors")
parser.add_argument(
"--no-overwrite",
action="store_true",
help="Do not overwrite output file if it already exists, simply ignore this file and continue processing other unprocessed files.",
dest="no_overwrite"
)

args = parser.parse_args()

Expand Down Expand Up @@ -1380,8 +1383,6 @@ def process_file(path, args):
"""
print("Processing %s..." % (path))

output_path = args.output_path

media_info = MediaInfo(
path,
verbose=args.is_verbose)
Expand All @@ -1392,6 +1393,16 @@ def process_file(path, args):
frame_type=args.frame_type
)

output_path = args.output_path
if not output_path:
output_path = media_info.filename + "." + args.image_format

if args.no_overwrite:
if os.path.exists(output_path):
print("[WARN] Output file already exists, skipping: {}".format(output_path))
return


# metadata margins
if not args.metadata_margin == DEFAULT_METADATA_MARGIN:
args.metadata_horizontal_margin = args.metadata_margin
Expand Down

0 comments on commit d3d6117

Please sign in to comment.