Himanshu Sharma
Himanshu Sharma

Reputation: 130

How to copy all the files created on a specific date from one bucket to another in GCS?

How can we copy all the files created on the specified date from one directory to another in GCS.

I have an archive folder from which I need to copy all the files that were created on a specified date(e.g. 20 August 2022) to another directory. We can do this by providing the list of filenames in a file and providing it as input to the gsutil cp command however I am having 500+ files and don't have the names of all of those.

Upvotes: 2

Views: 1860

Answers (2)

guillaume blaquiere
guillaume blaquiere

Reputation: 75910

You can use Data transfer service to copy data from one GCS to another one.

On the second step, select advanced filters and pick the absolute time range enter image description here

It should meet your expectation.

Upvotes: 3

Dev Yns
Dev Yns

Reputation: 229

Try this command :

gsutil ls -l gs://{SOURCE_BUCKET}/ | grep 2022-08-20 | rev | cut -d ' ' -f1 | rev | gsutil -m cp -I gs://{DESTINATION_BUCKET}/

Upvotes: 3

Related Questions