Skip to main content

rclone Mkdir

rclone mkdir creates a directory at the specified path on a remote. It's the equivalent of mkdir -p — parent directories are created automatically, and it's safe to call on an already-existing path.

Quick Summary

Most rclone commands auto-create directories as needed, so you rarely need mkdir explicitly. It's most useful for pre-creating bucket prefixes, verifying remote access, and scripted setup.

Basic Syntax

rclone mkdir REMOTE:PATH
# Create a directory on a remote
rclone mkdir remote:my-bucket/backups/daily

# Create nested path (parent dirs created automatically)
rclone mkdir remote:my-bucket/projects/2024/q1/reports

# Create a local directory
rclone mkdir /var/backups/rclone/daily

Practical Examples

Pre-Create Backup Directories

# Set up backup directory structure
rclone mkdir remote:backups/daily
rclone mkdir remote:backups/weekly
rclone mkdir remote:backups/monthly

Verify Remote Access

# Use mkdir as a quick write-access test
rclone mkdir remote:test-access && echo "Write access OK" || echo "Write access FAILED"
rclone rmdir remote:test-access # Clean up

Scripted Setup

setup-remote.sh
#!/bin/bash
REMOTE="backup-s3"
BUCKET="my-company-backups"

for dir in daily weekly monthly configs db-dumps; do
rclone mkdir "${REMOTE}:${BUCKET}/${dir}"
echo "Created ${REMOTE}:${BUCKET}/${dir}"
done

Object Storage Note

tip

On object storage backends (S3, GCS, Azure Blob), directories don't truly exist as separate entities — they're implied by object key prefixes. rclone mkdir on these backends typically creates a zero-byte placeholder object. Once you upload files under that prefix, the directory "exists" naturally.

Common Pitfalls

PitfallConsequencePrevention
Thinking mkdir is required before copyUnnecessary step — copy creates dirsOnly use mkdir when you specifically need empty dirs
Path typoCreates a wrong directory silentlyVerify with rclone lsd after creation

What's Next

Examples with Output

1. Create a remote directory

Initialize a new folder for your backups. Command:

rclone mkdir gdrive:NewBackups

Output:

(No output on success)

2. Create nested directories

Automatically build the parent folders if they don't exist. Command:

rclone mkdir remote:ProjectX/Exports/2024

Output:

(Full path created on the remote)

3. Create a local directory

Use rclone as a platform-agnostic alternative to mkdir -p. Command:

rclone mkdir ./local_staging/data

Output:

(Local directory tree created)

4. Create directory on S3 (Bucket check)

Verify and create the path in object storage. Command:

rclone mkdir s3-backup:my-new-bucket/temp -v

Output:

2024/01/15 12:00:00 INFO  : S3 bucket my-new-bucket: Bucket "my-new-bucket" created

5. Idempotent check

Running mkdir on an existing directory does nothing. Command:

rclone mkdir remote:ExistingFolder && echo "Done"

Output:

Done