Renaming Empty Folders in S3

0

Hi Experts, I didn't find a similar question asked anywhere else, so spare me and point me if this has been previously asked.

I am using AWS Cli to rename folders recursively using mv command in S3. However only those folders which have a file in them are renamed. Empty folders are kept untouched.

e.g. consider the following structure

a\b\1.txt

a\b\2.txt

a\b\c\

a\b\c\d\

In case the folder b above is renamed to x, the following will be revised structure. See that last empty folder c is unchanged.

a\x\1.txt

a\x\2.txt

a\b\c\

a\b\c\d\

Is there a way to perform a complete rename, even if it's an empty folder?

Any assistance would be appreciated.

Regards, Anshul

질문됨 2년 전357회 조회
1개 답변
0

I think you might have to clean these up. Here is how to find the folders that did not get moved:

aws s3api list-objects \
    --bucket test-bucket \
    --query 'Contents[?ends_with(Key, `/`) && contains(Key, `b/`)].Key'
profile pictureAWS
전문가
kentrad
답변함 2년 전
  • Thanks. But that means I will need to recreate all the empty folders again at the target location. That might not be a good thing performance wise, in case the nested folders are deeper to many levels.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠