Created
September 21, 2017 17:15
-
-
Save fellipecaetano/9c59eb2a977c742eedfbf72030fe7ebb to your computer and use it in GitHub Desktop.
Duplicate current set of snapshots, changing the versions on the copies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import argparse | |
import glob | |
import shutil | |
import re | |
arg_parser = argparse.ArgumentParser() | |
arg_parser.add_argument('--reference-image-folder', | |
dest='reference_image_folder') | |
arg_parser.add_argument('--previous-version', dest='previous_version') | |
arg_parser.add_argument('--new-versions', nargs='+', dest='new_versions') | |
args = arg_parser.parse_args() | |
glob_pattern = '{}/**/*.png'.format(args.reference_image_folder) | |
for snapshot_file in glob.iglob(glob_pattern): | |
for new_version in args.new_versions: | |
duplicated_file = re.sub(args.previous_version, new_version, | |
snapshot_file) | |
if duplicated_file != snapshot_file: | |
shutil.copy(snapshot_file, duplicated_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment