コード例 #1
0
def main():
    """
    Command-line interface for using the XMP features of photofile.
    """
    parser = OptionParser()

    xmp_group = OptionGroup(parser, "XMP options")
    xmp_group.add_option(
        "-i",
        "--search_sidecar",
        dest="sidecar_keywords",
        action="callback",
        callback=cb,
        help=
        "Searches any sidecar/XMP-files found in target for tags with a specific content"
    )
    parser.add_option_group(xmp_group)

    add_common_options(parser)
    (options, args) = parser.parse_args()
    check_common_options(options, args)

    if options.sidecar_keywords and options.target:
        print(options.sidecar_keywords)
        sys.exit(0)
コード例 #2
0
ファイル: gps.py プロジェクト: connectthefuture/mediaphile
def main():
    """
    Command-line interface for using the GPS related features of photofile.
    """
    parser = OptionParser()

    common_group = OptionGroup(parser, "Common parameters")
    common_group.add_option("-s",
                            "--source",
                            dest="source",
                            help="the source folder to process")
    common_group.add_option("-t",
                            "--target",
                            dest="target",
                            help="the target folder for new files")
    common_group.add_option(
        "--dry-run",
        dest="dru_run",
        action="store_true",
        help="Just do a test-run. No actual changes will be made")
    parser.add_option_group(common_group)

    add_common_options(parser)
    (options, args) = parser.parse_args()
    check_common_options(options, args)
コード例 #3
0
def main():
    """
    Command-line interface for using the thumbnail features of photofile.
    """
    parser = OptionParser()

    common_group = OptionGroup(parser, "Common parameters")
    common_group.add_option("-s", "--source", dest="source", help="the source folder to process")
    common_group.add_option("-t", "--target", dest="target", help="the target folder for new files")
    common_group.add_option("--dry-run", dest="dru_run", action="store_true",
                            help="Just do a test-run. No actual changes will be made")
    parser.add_option_group(common_group)

    thumb_group = OptionGroup(parser, "Thumbnail generation")
    thumb_group.add_option("-w", "--generate_thumbnails", dest="generate_thumbnails", action="store_true",
                      help="Creates thumbnails target folder for all photos in source folder")
    thumb_group.add_option("-o", "--dimensions", dest="thumbnail_dimensions", action="store",
                      help="""Dimensions for thumbnail in pixels, for example 400x400 (height X width).
                      Can also generate thumbnail with different dimensions by providing a list of dimensions, like:
                      -o 400x400,800x600,1024x768. NB! No spaces!""")
    thumb_group.add_option("--crop", dest="crop_thumbnails", action="store_true",
                      help="Crops thumbnails and uses width and height values as boundries")
    parser.add_option_group(thumb_group)

    add_common_options(parser)
    (options, args) = parser.parse_args()
    check_common_options(options, args)

    if not options.source and not options.target:
        print("ERROR: You must supply both source- and target-folders.\n")
        sys.exit(1)

    elif options.generate_thumbnails:
        pass
コード例 #4
0
ファイル: movies.py プロジェクト: connectthefuture/mediaphile
def main():
    """
    Command-line interface for using the movie related features of photofile.
    """
    parser = OptionParser()

    common_group = OptionGroup(
        parser,
        "Relocates movies by creation date into a date-based hierarchy")
    common_group.add_option("-s",
                            "--source",
                            dest="source",
                            help="the source folder to process")
    common_group.add_option("-t",
                            "--target",
                            dest="target",
                            help="the target folder for new files")
    common_group.add_option(
        "--dry-run",
        dest="dru_run",
        action="store_true",
        help="Just do a test-run. No actual changes will be made")
    parser.add_option_group(common_group)

    add_common_options(parser)
    (options, args) = parser.parse_args()
    check_common_options(options, args)

    if not options.source and not options.target:
        print("ERROR: You must supply both source- and target-folders.\n")
        sys.exit(1)

    relocate_movies(options.source, options.target)
コード例 #5
0
def main():
    """
    Command-line interface for using photo and image related functions of photofile.
    """
    parser = OptionParser()

    common_group = OptionGroup(parser, "Relocates photos and images by EXIF/creation date into a date-based hierarchy")
    common_group.add_option("-s", "--source", dest="source", help="the source folder to process")
    common_group.add_option("-t", "--target", dest="target", help="the target folder for new files")
    common_group.add_option("-d", "--delete", dest="delete", action="store_true",
                            help="delete source files when processed")
    common_group.add_option("--dry-run", dest="dry_run", action="store_true",
                            help="Just do a test-run. No actual changes will be made")
    common_group.add_option("-p", "--path-prefix", dest="path_prefix",
                            help="a prefix to prepend all files when they are processed")
    common_group.add_option("-x", "--skip-existing", dest="skip_existing", action="store_true",
                            help="skip moving existing files when processing")
    common_group.add_option("--configuration-folder", dest="configuration_folder",
                            help="folder containing mediaphile.ini to use")
    common_group.add_option("-l", "--list", dest="list", action="store_true",
                            help="list all files in source folder with photo specific data")
    common_group.add_option("-a", "--auto-tag", dest="auto_tag", action="store_true",
                            help="use prepending folders as tags instead of day part from date")
    common_group.add_option("--tag", dest="tag", help="tag to use instead of day part from date")
    parser.add_option_group(common_group)

    add_common_options(parser)
    (options, args) = parser.parse_args()
    check_common_options(options, args)

    if options.list:
        if not options.source:
            print("You must provide a source when using the -l option.")
            sys.exit(1)

        list_photos(options.source)

    elif not options.source and not options.target:
        print("ERROR: You must supply both source- and target-folders.\n")
        print_help(parser)
        sys.exit(1)

    config = get_user_config(options.configuration_folder or None)

    relocate_photos(
        source_dir=options.source,
        target_dir=options.target,
        append_timestamp=config.getboolean('options', 'append timestamp') or False,
        remove_source=options.delete,
        tag=options.tag,
        dry_run=options.dry_run,
        photo_extensions_to_include=[ext.strip() for ext in config.get('options', 'photo extensions').split(',')],
        timestamp_format=config.get('options', 'timestamp format'),
        duplicate_filename_format=config.get('options', 'duplicate filename format'),
        new_filename_format=config.get('options', 'new filename format'),
        path_prefix=options.path_prefix,
        skip_existing=options.skip_existing or config.getboolean('options', 'skip existing'),
        auto_tag=options.auto_tag or config.getboolean('options', 'auto tag'))
コード例 #6
0
def main():
    """
    Command-line interface for using the thumbnail features of photofile.
    """
    parser = OptionParser()

    common_group = OptionGroup(parser, "Common parameters")
    common_group.add_option("-s",
                            "--source",
                            dest="source",
                            help="the source folder to process")
    common_group.add_option("-t",
                            "--target",
                            dest="target",
                            help="the target folder for new files")
    common_group.add_option(
        "--dry-run",
        dest="dru_run",
        action="store_true",
        help="Just do a test-run. No actual changes will be made")
    parser.add_option_group(common_group)

    thumb_group = OptionGroup(parser, "Thumbnail generation")
    thumb_group.add_option(
        "-w",
        "--generate_thumbnails",
        dest="generate_thumbnails",
        action="store_true",
        help="Creates thumbnails target folder for all photos in source folder"
    )
    thumb_group.add_option(
        "-o",
        "--dimensions",
        dest="thumbnail_dimensions",
        action="store",
        help=
        """Dimensions for thumbnail in pixels, for example 400x400 (height X width).
                      Can also generate thumbnail with different dimensions by providing a list of dimensions, like:
                      -o 400x400,800x600,1024x768. NB! No spaces!""")
    thumb_group.add_option(
        "--crop",
        dest="crop_thumbnails",
        action="store_true",
        help="Crops thumbnails and uses width and height values as boundries")
    parser.add_option_group(thumb_group)

    add_common_options(parser)
    (options, args) = parser.parse_args()
    check_common_options(options, args)

    if not options.source and not options.target:
        print("ERROR: You must supply both source- and target-folders.\n")
        sys.exit(1)

    elif options.generate_thumbnails:
        pass
コード例 #7
0
ファイル: file.py プロジェクト: connectthefuture/mediaphile
def main():
    """
    Command-line interface for using the file related features of photofile.
    """
    parser = OptionParser()

    common_group = OptionGroup(parser, "Common parameters")
    common_group.add_option("-s", "--source", dest="source", help="the source folder to process")
    common_group.add_option("-t", "--target", dest="target", help="the target folder for new files")
    common_group.add_option("--dry-run", dest="dry_run", action="store_true",
                            help="Just do a test-run. No actual changes will be made.")
    parser.add_option_group(common_group)

    duplicate_group = OptionGroup(parser, "Duplicate handling")
    duplicate_group.add_option("-d", "--find_duplicates", action="store_true",
                               help="locates duplicates in source folder compared to target folder",
                               dest="find_duplicates")
    duplicate_group.add_option("-x", "--delete_duplicates", action="store_true", dest="delete",
                               help="deletes any duplicate file from source folder found in both source and target folder")
    duplicate_group.add_option("-r", "--rename", action="store_true", dest="rename",
                               help="renames any duplicate file in the source folder found in both source and target folder")
    parser.add_option_group(duplicate_group)

    new_content_group = OptionGroup(parser, "Finding new files")
    new_content_group.add_option("-n", "--new_files",
                                 help="locates new files in source folder compared to target folder",
                                 dest="new_files")
    parser.add_option_group(new_content_group)

    add_common_options(parser)
    (options, args) = parser.parse_args()
    check_common_options(options, args)

    if options.delete and options.rename:
        print("Error: you cannot delete and rename in the same process. Chose one.")
        sys.exit(1)

    if not options.source and not options.target:
        print("ERROR: You must supply both source- and target-folders.\n")
        sys.exit(1)

    print(vars(options))

    if options.find_duplicates:
        list(find_duplicates(
            options.source,
            options.target,
            delete_duplicates=options.delete,
            rename_duplicates=options.rename,
            dry_run=options.dry_run,
            verbose=options.verbose
        ))
コード例 #8
0
ファイル: db.py プロジェクト: havardgulldahl/mediaphile
def main():
    """
    Command-line interface for using the persistence storage or database features of photofile.
    """
    parser = OptionParser()

    common_group = OptionGroup(parser, "Common parameters")
    common_group.add_option("-s", "--source", dest="source", help="the source folder to process")
    common_group.add_option("--dry-run", dest="dru_run", action="store_true",
                            help="Just do a test-run. No actual changes will be made")
    parser.add_option_group(common_group)

    add_common_options(parser)
    (options, args) = parser.parse_args()
    check_common_options(options, args)
コード例 #9
0
ファイル: xmp.py プロジェクト: havardgulldahl/mediaphile
def main():
    """
    Command-line interface for using the XMP features of photofile.
    """
    parser = OptionParser()

    xmp_group = OptionGroup(parser, "XMP options")
    xmp_group.add_option("-i", "--search_sidecar", dest="sidecar_keywords", action="callback", callback=cb,
                      help="Searches any sidecar/XMP-files found in target for tags with a specific content")
    parser.add_option_group(xmp_group)

    add_common_options(parser)
    (options, args) = parser.parse_args()
    check_common_options(options, args)

    if options.sidecar_keywords and options.target:
        print(options.sidecar_keywords)
        sys.exit(0)
コード例 #10
0
ファイル: movies.py プロジェクト: havardgulldahl/mediaphile
def main():
    """
    Command-line interface for using the movie related features of photofile.
    """
    parser = OptionParser()

    common_group = OptionGroup(parser, "Relocates movies by creation date into a date-based hierarchy")
    common_group.add_option("-s", "--source", dest="source", help="the source folder to process")
    common_group.add_option("-t", "--target", dest="target", help="the target folder for new files")
    common_group.add_option("--dry-run", dest="dru_run", action="store_true",
                            help="Just do a test-run. No actual changes will be made")
    parser.add_option_group(common_group)

    add_common_options(parser)
    (options, args) = parser.parse_args()
    check_common_options(options, args)

    if not options.source and not options.target:
        print("ERROR: You must supply both source- and target-folders.\n")
        sys.exit(1)

    elif options.relocate_movies:
        relocate_movies(options.source, options.target)