From a010ab5a299470782b938e689a7ddc336513065e Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Sun, 9 Jan 2022 07:58:14 -0800 Subject: [PATCH] Added uuid command --- osxphotos/cli.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/osxphotos/cli.py b/osxphotos/cli.py index e17db5aa..8f6650d3 100644 --- a/osxphotos/cli.py +++ b/osxphotos/cli.py @@ -4331,3 +4331,25 @@ def grep(ctx, cli_obj, db, ignore_case, print_filename, pattern): db_file, pattern, ignore_case, print_filename, rich_markup=True ): print(", ".join([table, column, row_id, value])) + + +@cli.command() +@click.pass_obj +@click.pass_context +@click.option( + "--filename", + "-f", + required=False, + is_flag=True, + default=False, + help="Include filename of selected photos in output", +) +def uuid(ctx, cli_obj, filename): + """Print out unique IDs (UUID) of photos selected in Photos + + Prints outs UUIDs in form suitable for --uuid-from-file and --skip-uuid-from-file + """ + for photo in photoscript.PhotosLibrary().selection: + if filename: + print(f"# {photo.filename}") + print(photo.uuid)