You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create Immich Albums from an external library path based on the top level folders
48
49
49
50
positional arguments:
50
-
root_path The external libarary's root path in Immich
51
+
root_path The external library's root path in Immich
51
52
api_url The root API URL of immich, e.g. https://immich.mydomain.com/api/
52
-
api_key The Immich API Key to use
53
+
api_key The Immich API Key to use. Set --api-key-type to 'file' if a file path is provided.
53
54
54
55
options:
55
56
-h, --help show this help message and exit
57
+
-t {literal,file}, --api-key-type {literal,file}
58
+
The type of the Immich API Key (default: literal)
56
59
-r ROOT_PATH, --root-path ROOT_PATH
57
-
Additional external libarary root path in Immich; May be specified multiple times for multiple import paths or external libraries. (default: None)
60
+
Additional external library root path in Immich; May be specified multiple times for multiple import paths or external libraries. (default: None)
58
61
-u, --unattended Do not ask for user confirmation after identifying albums. Set this flag to run script as a cronjob. (default: False)
59
62
-a ALBUM_LEVELS, --album-levels ALBUM_LEVELS
60
-
Number of sub-folders or range of sub-folder levels below the root path used for album name creation. Positive numbers start from top of the folder structure, negative numbers from the bottom. Cannot be 0. If a range should be set, the start level and end level
61
-
must be separated by a comma like '<startLevel>,<endLevel>'. If negative levels are used in a range, <startLevel> must be less than or equal to <endLevel>. (default: 1)
63
+
Number of sub-folders or range of sub-folder levels below the root path used for album name creation. Positive numbers start from top of the folder structure, negative numbers
64
+
from the bottom. Cannot be 0. If a range should be set, the start level and end level must be separated by a comma like '<startLevel>,<endLevel>'. If negative levels are used in
65
+
a range, <startLevel> must be less than or equal to <endLevel>. (default: 1)
Separator string to use for compound album names created from nested folders. Only effective if -a is set to a value > 1 (default: )
64
68
-c CHUNK_SIZE, --chunk-size CHUNK_SIZE
@@ -69,30 +73,41 @@ This script is mostly based on the following original script: [REDVM/immich_auto
69
73
Log level to use (default: INFO)
70
74
-k, --insecure Set to true to ignore SSL verification (default: False)
71
75
-i IGNORE, --ignore IGNORE
72
-
Use either literals or glob-like patterns to ignore assets for album name creation. This filter is evaluated after any values passed with --path-filter. May be specified multiple times. (default: None)
76
+
Use either literals or glob-like patterns to ignore assets for album name creation. This filter is evaluated after any values passed with --path-filter. May be specified
Mode for the script to run with. CREATE = Create albums based on folder names and provided arguments; CLEANUP = Create album nmaes based on current images and script arguments, but delete albums if they exist; DELETE_ALL = Delete all albums. If the mode is anything but CREATE, --unattended does not have any effect. Only performs deletion if -d/--delete-confirm option is set, otherwise only performs a dry-run. (default: CREATE)
75
-
-d, --delete-confirm Confirm deletion of albums when running in mode CLEANUP or DELETE_ALL. If this flag is not set, these modes will perform a dry run only. Has no effect in mode CREATE (default: False)
79
+
Mode for the script to run with. CREATE = Create albums based on folder names and provided arguments; CLEANUP = Create album nmaes based on current images and script arguments,
80
+
but delete albums if they exist; DELETE_ALL = Delete all albums. If the mode is anything but CREATE, --unattended does not have any effect. Only performs deletion if
81
+
-d/--delete-confirm option is set, otherwise only performs a dry-run. (default: CREATE)
82
+
-d, --delete-confirm Confirm deletion of albums when running in mode CLEANUP or DELETE_ALL. If this flag is not set, these modes will perform a dry run only. Has no effect in mode CREATE (default:
83
+
False)
76
84
-x SHARE_WITH, --share-with SHARE_WITH
77
-
A user name (or email address of an existing user) to share newly created albums with. Sharing only happens if the album was actually created, not if new assets were added to an existing album. If the the share role should be specified by user, the format
78
-
<userName>=<shareRole> must be used, where <shareRole> must be one of 'viewer' or 'editor'. May be specified multiple times to share albums with more than one user. (default: None)
85
+
A user name (or email address of an existing user) to share newly created albums with. Sharing only happens if the album was actually created, not if new assets were added to an
86
+
existing album. If the the share role should be specified by user, the format <userName>=<shareRole> must be used, where <shareRole> must be one of 'viewer' or 'editor'. May be
87
+
specified multiple times to share albums with more than one user. (default: None)
79
88
-o {viewer,editor}, --share-role {viewer,editor}
80
-
The default share role for users newly created albums are shared with. Only effective if --share-with is specified at least once and the share role is not specified within --share-with. (default: viewer)
89
+
The default share role for users newly created albums are shared with. Only effective if --share-with is specified at least once and the share role is not specified within
90
+
--share-with. (default: viewer)
81
91
-S {0,1,2}, --sync-mode {0,1,2}
82
-
Synchronization mode to use. Synchronization mode helps synchronizing changes in external libraries structures to Immich after albums have already been created. Possible Modes: 0 = do nothing; 1 = Delete any empty albums; 2 = Delete offline assets AND any empty albums (default: 0)
92
+
Synchronization mode to use. Synchronization mode helps synchronizing changes in external libraries structures to Immich after albums have already been created. Possible Modes:
93
+
0 = do nothing; 1 = Delete any empty albums; 2 = Delete offline assets AND any empty albums (default: 0)
Set sorting order for newly created albums to newest or oldest file first, Immich defaults to newest file first (default: False)
85
96
-A, --find-assets-in-albums
86
-
By default, the script only finds assets that are not assigned to any album yet. Set this option to make the script discover assets that are already part of an album and handle them as usual. If --find-archived-assets is set as well, both options apply. (default:
87
-
False)
97
+
By default, the script only finds assets that are not assigned to any album yet. Set this option to make the script discover assets that are already part of an album and handle
98
+
them as usual. If --find-archived-assets is set as well, both options apply. (default: False)
88
99
-f PATH_FILTER, --path-filter PATH_FILTER
89
-
Use either literals or glob-like patterns to filter assets before album name creation. This filter is evaluated before any values passed with --ignore. May be specified multiple times. (default: None)
100
+
Use either literals or glob-like patterns to filter assets before album name creation. This filter is evaluated before any values passed with --ignore. May be specified multiple
Set first/last/random image as thumbnail for newly created albums or albums assets have been added to. If set to random-filtered, thumbnails are shuffled for all albums whose assets would not be filtered out or ignored by the ignore or path-filter options, even if no assets were added during the run. If set to random-all, the thumbnails for ALL albums will be shuffled on every run. (default: None)
92
-
-v, --archive Set this option to automatically archive all assets that were newly added to albums. If this option is set in combination with --mode = CLEANUP or DELETE_ALL, archived images of deleted albums will be unarchived. Archiving hides the assets from Immich's timeline.
93
-
(default: False)
103
+
Set first/last/random image as thumbnail for newly created albums or albums assets have been added to. If set to random-filtered, thumbnails are shuffled for all albums whose
104
+
assets would not be filtered out or ignored by the ignore or path-filter options, even if no assets were added during the run. If set to random-all, the thumbnails for ALL
105
+
albums will be shuffled on every run. (default: None)
106
+
-v, --archive Set this option to automatically archive all assets that were newly added to albums. If this option is set in combination with --mode = CLEANUP or DELETE_ALL, archived images of
107
+
deleted albums will be unarchived. Archiving hides the assets from Immich's timeline. (default: False)
94
108
--find-archived-assets
95
-
By default, the script only finds assets that are not archived in Immich. Set this option to make the script discover assets that are already archived. If -A/--find-assets-in-albums is set as well, both options apply. (default: False)
109
+
By default, the script only finds assets that are not archived in Immich. Set this option to make the script discover assets that are already archived. If -A/--find-assets-in-
110
+
albums is set as well, both options apply. (default: False)
96
111
```
97
112
98
113
__Plain example without optional arguments:__
@@ -111,7 +126,8 @@ The environment variables are analoguous to the script's command line arguments.
| ROOT_PATH | yes | A single or a comma separated list of import paths for external libraries in Immich. <br>Refer to [Choosing the correct `root_path`](#choosing-the-correct-root_path).|
113
128
| API_URL | yes | The root API URL of immich, e.g. https://immich.mydomain.com/api/ |
114
-
| API_KEY | yes | The Immich API Key to use
129
+
| API_KEY | no | The Immich API Key to use. Either `API_KEY` or `API_KEY_FILE` must be specified. The `API_KEY` variable takes precedence for ease of manual execution, but it is recommended to use `API_KEY_FILE`.
130
+
| API_KEY_FILE | no | An absolute path (from the root of the container) to a file containing the Immich API Key. The file might be mounted into the container using a volume (e.g. `-v /path/to/api_key.secret:/immich_api_key.secret:ro`). The file must contain only the value. |
115
131
| CRON_EXPRESSION | yes | A [crontab-style expression](https://crontab.guru/) (e.g. `0 * * * *`) to perform album creation on a schedule (e.g. every hour). |
116
132
| ALBUM_LEVELS | no | Number of sub-folders or range of sub-folder levels below the root path used for album name creation. Positive numbers start from top of the folder structure, negative numbers from the bottom. Cannot be `0`. If a range should be set, the start level and end level must be separated by a comma. <br>Refer to [How it works](#how-it-works) for a detailed explanation and examples. |
117
133
| ALBUM_SEPARATOR | no | Separator string to use for compound album names created from nested folders. Only effective if `-a` is set to a value `> 1`(default: "` `") |
Copy file name to clipboardExpand all lines: immich_auto_album.py
+24-4Lines changed: 24 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -68,10 +68,11 @@ def glob_to_re(pattern):
68
68
}
69
69
70
70
parser=argparse.ArgumentParser(description="Create Immich Albums from an external library path based on the top level folders", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
71
-
parser.add_argument("root_path", action='append', help="The external libarary's root path in Immich")
71
+
parser.add_argument("root_path", action='append', help="The external library's root path in Immich")
72
72
parser.add_argument("api_url", help="The root API URL of immich, e.g. https://immich.mydomain.com/api/")
73
-
parser.add_argument("api_key", help="The Immich API Key to use")
74
-
parser.add_argument("-r", "--root-path", action="append", help="Additional external libarary root path in Immich; May be specified multiple times for multiple import paths or external libraries.")
73
+
parser.add_argument("api_key", help="The Immich API Key to use. Set --api-key-type to 'file' if a file path is provided.")
74
+
parser.add_argument("-t", "--api-key-type", default="literal", choices=['literal', 'file'], help="The type of the Immich API Key")
75
+
parser.add_argument("-r", "--root-path", action="append", help="Additional external library root path in Immich; May be specified multiple times for multiple import paths or external libraries.")
75
76
parser.add_argument("-u", "--unattended", action="store_true", help="Do not ask for user confirmation after identifying albums. Set this flag to run script as a cronjob.")
76
77
parser.add_argument("-a", "--album-levels", default="1", type=str, help="Number of sub-folders or range of sub-folder levels below the root path used for album name creation. Positive numbers start from top of the folder structure, negative numbers from the bottom. Cannot be 0. If a range should be set, the start level and end level must be separated by a comma like '<startLevel>,<endLevel>'. If negative levels are used in a range, <startLevel> must be less than or equal to <endLevel>.")
77
78
parser.add_argument("-s", "--album-separator", default=" ", type=str, help="Separator string to use for compound album names created from nested folders. Only effective if -a is set to a value > 1")
0 commit comments