gcloud storage batch-operations jobs create BATCH_JOB ((--bucket=BUCKET | --bucket-list=[BUCKETS,…]) (--included-object-prefixes=[PREFIXES,…] | --manifest-location=MANIFEST_LOCATION) | --dry-run-job-id=DRY_RUN_JOB_ID | [--insights-dataset-config=INSIGHTS_DATASET_CONFIG --target-project=TARGET_PROJECT : --bucket-filters=BUCKET_FILTERS --object-filters=OBJECT_FILTERS [--target-locations=[LOCATIONS,…] : --target-snapshot-time=TARGET_SNAPSHOT_TIME]]) (--put-metadata=KEY=VALUE,[KEY=VALUE,…] | --rewrite-object=KEY=VALUE,[KEY=VALUE,…] | --set-object-acls-from-file=ACL_UPDATES_FILE | --clear-all-object-custom-contexts | --clear-object-custom-contexts=[CUSTOM_CONTEXTS_KEYS,…] --update-object-custom-contexts=[CUSTOM_CONTEXTS_KEYS_AND_VALUES,…] | --update-object-custom-contexts-file=CUSTOM_CONTEXTS_FILE | [--delete-object : --enable-permanent-object-deletion] | --[no-]put-object-event-based-hold --[no-]put-object-temporary-hold) [--description=DESCRIPTION] [--dry-run] [--log-actions=[LOG_ACTIONS,…] --log-action-states=[LOG_ACTION_STATES,…]] [GCLOUD_WIDE_FLAG …]
my-dry-run, that performs a dry run of object deletion on bucket
my-bucket for objects specified in the manifest file
gs://my-bucket/manifest.csv:
gcloud storage batch-operations jobs create my-dry-run-job --bucket=my-bucket --manifest-location=gs://my-bucket/manifest.csv --delete-object --dry-run
The following example command creates a batch job, named my-job,
that performs object deletion on bucket my-bucket for objects
specified in the manifest file gs://my-bucket/manifest.csv:
gcloud storage batch-operations jobs create my-job --bucket=my-bucket --manifest-location=gs://my-bucket/manifest.csv --delete-object
The following example command creates a batch job, named my-job,
that performs object deletion on buckets my-bucket-1 and
my-bucket-2 for all objects in them:
gcloud storage batch-operations jobs create my-job --bucket-list=my-bucket-1,my-bucket-2 --included-object-prefixes='' --delete-object
The following example command creates a batch job, named my-job,
that updates object metadata Content-Disposition to
inline, Content-Language to en, and sets
object retention mode to locked on bucket my-bucket
for objects with prefixes prefix1 or prefix2:
gcloud storage batch-operations jobs create my-job --bucket=my-bucket --included-object-prefixes=prefix1,prefix2 --put-metadata=Content-Disposition=inline,Content-Language=en,Retain-Until=2025-01-01T00:00:00Z,Retention-Mode=locked
The following example command creates a batch job, named my-job,
that removes the object custom context key1 and updates
key2 to val2 and key3 to
val3 on bucket my-bucket for objects with prefixes
prefix1 or prefix2:
gcloud storage batch-operations jobs create my-job --bucket=my-bucket --included-object-prefixes=prefix1,prefix2 --clear-object-custom-contexts=key1 --update-object-custom-contexts=key2=val2,key3=val3
The following example command creates a batch job, named my-job,
that puts object event based hold on objects in bucket my-bucket
with logging config enabled for corresponding transform action and succeeded and
failed action states:
gcloud storage batch-operations jobs create my-job --bucket=my-bucket --put-object-event-based-hold --put-metadata=Content-Disposition=inline,Content-Language=en --log-actions=transform --log-action-states=succeeded,failed
The following example command creates a batch job, named my-job,
that uses a project as the source and updates object retention:
gcloud storage batch-operations jobs create my-job --target-project=my-project --insights-dataset-config=projects/my-project/locations/us-central1/datasetConfigs/my-config --bucket-filters="bucket_name == 'my-bucket'" --object-filters="size > 100" --put-metadata=Retain-Until=2025-01-01T00:00:00Z,Retention-Mode=locked
The following example command creates a batch job, named my-job,
that uses a project as the source with specific target locations and snapshot
timestamp:
gcloud storage batch-operations jobs create my-job --target-project=my-project --insights-dataset-config=projects/my-project/locations/us-central1/datasetConfigs/my-config --target-locations=us-central1,us-east1 --target-snapshot-time=2024-01-02T03:04:05Z --put-metadata=Retention-Mode=locked
To set the project attribute:
batch_job on the command line with a fully
specified name;
--project on the command line;
core/project.
To set the location attribute:
batch_job on the command line with a fully
specified name;
global.
BATCH_JOBbatch-job attribute:
batch_job on the command line.
--bucket=BUCKET--bucket-list=[BUCKETS,…]--manifest-location=``MANIFEST_LOCATION or
--included-object-prefixes=``COMMA_SEPARATED_PREFIXES
Exactly one of these must be specified:
--included-object-prefixes=[PREFIXES,…]--manifest-location=MANIFEST_LOCATION--manifest-location=gs://bucket_name/path/manifest_name.csv
--dry-run-job-id=DRY_RUN_JOB_ID--insights-dataset-config=INSIGHTS_DATASET_CONFIG--target-project=TARGET_PROJECT--bucket-filters=BUCKET_FILTERS--object-filters=OBJECT_FILTERS--target-locations=[LOCATIONS,…]--target-snapshot-time=TARGET_SNAPSHOT_TIME--put-metadata=KEY=VALUE,[KEY=VALUE,…]Content-Disposition={VALUE}. To set how content is
encoded (e.g. "gzip"), specify the key-value pair
Content-Encoding={VALUE}. To set content's language (e.g. "en"
signifies "English"), specify the key-value pair
Content-Language={VALUE}. To set the type of data contained in the
object (e.g. "text/html"), specify the key-value pair
Content-Type={VALUE}. To set how caches should handle requests and
responses, specify the key-value pair Cache-Control={VALUE}. To set
custom time for Cloud Storage objects in RFC 3339 format, specify the key-value
pair Custom-Time={VALUE}. To set object retention, specify
Retain-Until={TIMESTAMP} in RFC 3339 format and
Retention-Mode={MODE} where mode can be Locked or
Unlocked. To set custom metadata on objects, specify key-value
pairs {CUSTOM-KEY}:{VALUE}. Note that all predefined keys (e.g.
Content-Disposition) are case-insensitive. Any other key that is not specified
above will be treated as a custom key. To clear a field, provide the key with an
empty value (e.g. Content-Disposition=). Multiple key-value pairs
can be specified by separating them with commas. For example,
--put-metadata=Content-Disposition=inline,Content-Encoding=gzip
--rewrite-object=KEY=VALUE,[KEY=VALUE,…]kms-key={KEY}. To
rewrite the object storage classes, specify the key-value pair
storage-class={STORAGE_CLASS} where storage-class can be one of
STANDARD, NEARLINE, COLDLINE, or
ARCHIVE. If an object's storage class is set to a different value
than it currently has, a full byte copy of the object will be made. If Autoclass
is enabled on the bucket, storage class changes will be ignored by Cloud
Storage. A metadata field MUST be specified, and multiple key-value pairs can be
specified by separating them with commas. For example:
--rewrite-object=kms-key=projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/CRYPTO_KEY,storage-class=STANDARD
--set-object-acls-from-file=ACL_UPDATES_FILEgrants:
For example:
grants:--clear-all-object-custom-contexts--update-object-custom-contexts and
--clear-object-custom-contexts.
--clear-object-custom-contexts=[CUSTOM_CONTEXTS_KEYS,…]--clear-object-custom-contexts=key1,key2
--update-object-custom-contexts=[CUSTOM_CONTEXTS_KEYS_AND_VALUES,…]--update-object-custom-contexts=key1=val1,key2=val2
--update-object-custom-contexts-file=CUSTOM_CONTEXTS_FILE1. The following JSON document shows two key value pairs, i.e. (key1, value1) and (key2, value2):
{ "key1": {"value": "value1"}, "key2": {"value": "value2"} }
2. The following YAML document shows two key value pairs, i.e. (key1, value1) and (key2, value2):
key1: value: value1 key2: value: value2
--delete-object--enable-permanent-object-deletion--[no-]put-object-event-based-hold--put-object-event-based-hold to enable and
--no-put-object-event-based-hold to disable.
--[no-]put-object-temporary-hold--put-object-temporary-hold to enable and
--no-put-object-temporary-hold to disable.
--description=DESCRIPTION--dry-run--log-actions=[LOG_ACTIONS,…]LOG_ACTIONS must be (only one value is supported):
transform.
--log-action-states=[LOG_ACTION_STATES,…]LOG_ACTION_STATES
must be one of: failed, succeeded.
--access-token-file,
--account, --billing-project,
--configuration,
--flags-file,
--flatten, --format, --help, --impersonate-service-account,
--log-http,
--project, --quiet, --trace-token, --user-output-enabled,
--verbosity.
Run $ gcloud help for details.
gcloud alpha storage batch-operations jobs create
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-06-02 UTC.