del (delete objects)

Top  Previous  Next

del [BUCKET_NAME]/[FOLDER]/OBJECT [-s] [-r] [-sim] [-stoponerror] [-cond:"FILTER"] [-include:INCL] [-exclude:EXCL] [-rinclude:INCL] [-rexclude:EXCL] [-inclenc] [-exclenc] [-inclrr] [-exclrr] [-inclia] [-exclia] [-inclgl] [-exclgl] [-inclle] [-exclle] [-noconfirm:X] [-version:ID] [-inclversions] [-onlyprev] [-minoutput]

Delete S3 objects.

 

Parameter

Description

Examples

[BUCKET_NAME]/[FOLDER]/OBJECT

Name of the bucket, folder, object(s) to delete.

If not specified, objects in current location are deleted.

Wildcard character can be used (i.e. * and ?) like in Windows dir. If object name have spaces, they must be surrounded by  quotation marks (") on the command line.

del mybucket/*.txt  (delete all objects with extension txt in mybucket)

del mybucket/myfolder/*.txt  (delete all objects with extension txt in mybucket/myfolder/)

del "mybucket/my folder/*.txt"  (delete all objects with extension txt in mybucket/my folder/, using quotation marks)

-s

Recursive deleting, e.g. process all subfolders.

del mybucket/* -s  (delete all objects from mybucket)

-r

Regular expression. This flag specifies that [BUCKET_NAME]/[FOLDER]/OBJECT must be treated as a regular expression.

del "mybucket/my folder/.*\.txt|.*\.vsn" -r  (delete all objects with extension txt or vsn in mybucket/my folder/)

del mybucket/^r.* -r  (delete all objects starting with 'r' in mybucket)

-sim

Only preview which objects would be deleted, do not actually delete the objects.

del mybucket/* -sim  (preview object deletion from mybucket)

-stoponerror

Stop deleting files as soon as an error occurs (do not continue with other files).

del mybucket/*.txt -stoponerror  (delete all objects with extension txt in mybucket, stop if, and as soon, as an error occurs, e.g. do not continue with other files)

-cond:
"FILTER"

Filter condition. Only delete objects matching the specified condition. More info on filter condition syntax and variables.

del mybucket -s -cond:"extract_value(cache-control,'max-age') > 0" (delete all objects in mybucket (recursive, include subfolders) with cache-control:max-age > 0 in the metadata)

del mybucket -s -cond:"size = 0" (delete all objects in mybucket (recursive) of size equal to zero)

del mybucket -cond:"name starts_with 'a'" (delete all objects in mybucket (non-recursive) with name starting with a)

del mybucket -s -cond:"name starts_with 'a' and size > 0" (delete all objects in mybucket (recursive) with name starting with a and size > 0)

More info on filter condition syntax and variables

-include:INCL

Only include objects matching specified mask (Wildcards). Separate multiple masks with "|".

del mybucket -include:*.jpg (delete all jpg files in mybucket)

del mybucket -include:*.jpg|*.gif (delete all jpg and gif files in mybucket)

-exclude:EXCL

Exclude objects matching specified mask (Wildcards). Separate multiple masks with "|".

del mybucket -exclude:*.jpg (delete all files in mybucket but exclude jpg files)

del mybucket -exclude:*.jpg|*.gif (delete all files in mybucket but exclude jpg files)

-rinclude:INCL

Only include objects matching specified mask (Regular Expression).

del mybucket -rinclude:a(x|y|z)b (delete files in mybucket matching axb, ayb and azb)

del mybucket -rinclude:*.(gif|bmp|jpg) (delete files in mybucket matching anything ending with .gif, .bmp or .jpg)

del mybucket -rinclude:"IMGP[0-9]{4}.jpg" (delete files in mybucket ending with .jpg , starting with IMG and followed by a four-digit number)

-rexclude:EXCL

Exclude objects matching specified mask (Regular Expression).

del mybucket -rexclude:[abc] (delete all files in mybucket but exclude files containing a, b or c)

-inclenc
-exclenc

Include only server-side encrypted files.
Exclude server-side encrypted files.

del mybucket -inclenc (delete all files in mybucket that are server-side encrypted)

del mybucket -exclenc (delete all files in mybucket that are NOT server-side encrypted)

-inclrr
-exclrr

Include only reduced redundancy files.

Exclude reduced redundancy files.

del mybucket -inclrr (delete all files in mybucket that are reduced redundancy)

del mybucket -exclrr (delete all files in mybucket that are NOT reduced redundancy)

-inclia

-exclia

Include only infrequent access files.

Exclude infrequent access files.

del mybucket -inclia (delete all files in mybucket that are infrequent access)

del mybucket -exclia (delete all files in mybucket that are NOT infrequent access)

-inclgl
-exclgl

Include only Glacier files.

Exclude Glacier files.

del mybucket -inclgl (delete all files in mybucket that are part of Amazon Glacier)

del mybucket -exclgl (delete all files in mybucket that are NOT part of Amazon Glacier)

-inclle
-exclle

Include only client-side (locally) encrypted files.

Exclude only client-side (locally) encrypted files.

del mybucket -inclle (delete all files in mybucket that were locally encrypted)

del mybucket -exclle (delete all files in mybucket that were NOT locally encrypted)

-noconfirm:X

Use -noconfirm to disable the deletion confirmation request "Confirm deletion of ..." that appears if more than 1 object is selected to be deleted.
You can use also -noconfirm with a value, e.g. -noconfirm:10. This would disable the confirmation request only for up to 10 files: if more than 10 files are selected to be deleted the confirmation question is still shown.

del mybucket -s -noconfirm (delete all files in mybucket and subfolders and do not ask for confirmation)
del mybucket -s -noconfirm:100 (delete all files in mybucket and subfolders and do not ask for confirmation if 100 or less files are selected to be deleted. Ask for confirmation if more than 100 files are selected to be deleted.)

-inclversions

Include object previous versions (for buckets with object versioning enabled).

del mybucket/*.txt -inclversions (delete all objects with extension txt in mybucket and also all previous versions of the objects)

-version:ID

Specify version ID of object to be deleted (for buckets with object versioning enabled).

del mybucket/file.txt -version:23443232 (delete object file.txt, object version ID 23443232, in mybucket)

-onlyprev

Include only the previous versions of an object. All current versions of objects are excluded (for buckets with object versioning enabled).

del mybucket/*.txt -onlyprev -cond:"s3_age_months>6" (delete all and only previous versions of objects with extension txt in mybucket, which are older than 6 months)

-minoutput

Minimal output. Minimize the output that is shown in the S3Express console during a delete operation. Only the total files deleted and eventual errors will be shown.

del mybucket/* -s  -minoutput (delete all objects from mybucket, show minimal output)

 

Notes:
- Use  quotation marks (") if folder or object names contain blank spaces, e.g. del "mybucket/my folder/name with a space.txt"
- If multiple files are to be deleted, file deletion will be done using multiple concurrent threads. The maximum threads to use can be specified with the command setopt , option -qmaxthreads