Mass rename objects on Google Cloud Storage -


is possible mass rename objects on google cloud storage using gsutil (or other tool)? trying figure out way rename bunch of images *.jpg *.jpg.

https://cloud.google.com/storage/docs/gsutil/addlhelp/wildcardnames

gsutil supports uri wildcards

edit

gsutil 3.0 release note

as part of bucket sub-directory support changed * wildcard match directory boundaries, , introduced new ** wildcard...

do have directories under bucket? if so, maybe need go down each directories or use **.

gsutil -m mv gs://my_bucket/**.jpg gs://my_bucket/**.jpg 

or

gsutil -m mv gs://my_bucket/mydir/*.jpg gs://my_bucket/mydir/*.jpg 

edit
gsutil doesn't support wildcard destination far (as of 4/12/'14)
nether api.

so @ moment need retrieve list of jpg files, , rename each files.

python example:

import subprocess files = subprocess.check_output("gsutil ls gs://my_bucket/*.jpg",shell=true) files = files.split("\n")[:-1] f in files:     subprocess.call("gsutil mv %s %s"%(f,f[:-3]+"jpg"),shell=true) 

please note take hours.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

qt - How to embed QML toolbar and menubar into QMainWindow -