How to quickly delete iDrive e2 files from Mac using AWS CLI

How to delete iDrive e2 files using AWS CLI on Mac

When you need to delete large amounts of files from an iDrive e2 bucket, doing it through the web interface can take hours or even days. The most efficient solution is to use AWS CLI from your Mac terminal, as it processes multiple files in parallel and significantly speeds up the process.

This guide shows you how to install and configure AWS CLI to delete folders or empty iDrive e2 buckets.

Prerequisites

To follow this guide you need:

  • Terminal access
  • iDrive e2 credentials (Access Key and Secret Key)
  • The endpoint, bucket name, and folder to delete

Step-by-step solution

Step 1: Install Homebrew (if you don't have it)

Homebrew is a package manager for Mac that makes it easy to install tools. Open Terminal and run:

  1. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

To verify it was installed correctly:

  1. brew --version

Step 2: Install AWS CLI

With Homebrew installed, run:

  1. brew install awscli
Verify the installation:
  1. aws --version

You should see something like aws-cli/2.x.x Python/3.x.x Darwin/...

Step 3: Configure the iDrive profile

Create a specific profile for iDrive by running:

  1. aws configure --profile idrive

The system will ask for the following information:

  • AWS Access Key ID: Your iDrive e2 Access Key
  • AWS Secret Access Key: Your iDrive e2 Secret Key
  • Default region name: Press Enter (leave empty)
  • Default output format: Type json

Step 4: Verify the connection

Before deleting, verify that you can see the bucket contents. Replace the values with your information:

  1. aws s3 ls s3://bucket-name/folder/ --endpoint-url=https://your-endpoint.idrivee2.com --profile idrive

If you see the list of files and folders, the configuration is correct.

Step 5: Delete the files

Run the following command to recursively delete all contents of a folder:

  1. aws s3 rm s3://bucket-name/folder/ --recursive --endpoint-url=https://your-endpoint.idrivee2.com --profile idrive

The process will display each file being deleted. Depending on the number of files, this may take minutes or hours.

Speed up the process (optional)

If you have millions of files, you can increase speed by configuring more simultaneous connections:

  1. aws configure set default.max_concurrent_requests 20 --profile idrive

After configuring this, run the delete command from Step 5 again.

Leave the process running overnight

If the process will take many hours, follow these steps to prevent your Mac from sleeping:

Option A: Use caffeinate in another terminal

  1. Leave the delete command running in the current terminal
  2. Open a new terminal tab or window
  3. Run: caffeinate -i

This will keep the Mac awake until you press Ctrl+C in that window.

Option B: Run in background with log

If you prefer to be able to close the terminal:

  1. nohup aws s3 rm s3://bucket-name/folder/ --recursive --endpoint-url=https://your-endpoint.idrivee2.com --profile idrive > deletion.log 2>&1 &

To view progress:

  1. tail -f deletion.log

To verify the process is still running:

  1. ps aux | grep aws

Verify everything was deleted

Once the process is finished, verify the folder is empty:

  1. aws s3 ls s3://bucket-name/folder/ --endpoint-url=https://your-endpoint.idrivee2.com --profile idrive

If it shows no results, the deletion was successful.

What does each command do?

  • aws s3 ls: Lists the contents of a bucket or folder
  • aws s3 rm --recursive: Deletes files and subfolders recursively
  • aws s3 rb: Removes an empty bucket
  • --endpoint-url: Specifies the iDrive e2 server
  • --profile idrive: Uses the credentials saved in the "idrive" profile
  • caffeinate -i: Prevents the Mac from entering sleep mode
  • nohup ... &: Runs a command in the background that continues even if you close the terminal

Important tips

  • Don't run the same command in multiple terminals - It causes conflicts and errors, it doesn't speed up the process
  • Keep your credentials in a safe place - The Access Key and Secret Key give full access to your storage
  • Always verify the correct bucket and folder - Deletion is irreversible

Need additional help? Contact our technical support team for personalized assistance.