Skip to main content

rclone Lsf

rclone lsf lists files and/or directories with a format you control. Unlike ls and lsd, it's designed for machine-readable output — making it perfect for shell scripts, piping, and automation.

Quick Summary

lsf outputs one item per line with no extra whitespace. You can customize which fields appear (size, time, hash, path) using the --format flag. Directories are indicated with a trailing /.

Basic Syntax​

rclone lsf REMOTE:PATH [flags]
# List files and dirs at top level (default: names only)
rclone lsf remote:my-bucket

# Recursive listing
rclone lsf remote:my-bucket -R

# Custom format
rclone lsf remote:my-bucket --format "sp" --separator " "

Default Output​

backups/
configs/
documents/
report.pdf
data.csv

Directories end with /, files don't.

Format Flags​

The --format flag controls which fields are shown. Each character adds a field:

CharacterFieldExample
pPath (default)documents/report.pdf
sSize (bytes)12345
tModification time2024-01-15 10:30:00
hHashd41d8cd98f00b204e9800998ecf8427e
iID (backend-specific)abc123
oOriginal (backend-specific)varies
mMIME typeapplication/pdf
eEncrypted name(crypt backend)
# Show size and path
rclone lsf remote:my-bucket --format "sp"

# Show size, time, and path
rclone lsf remote:my-bucket --format "stp"

# Show hash and path
rclone lsf remote:my-bucket --format "hp" --hash MD5

Key Flags​

FlagDescription
-R / --recursiveList recursively
--format FORMATOutput field format string
--separator SEPField separator (default ;)
--dir-slashShow trailing / on directories (default true)
--dirs-onlyShow only directories
--files-onlyShow only files
--max-depth NLimit recursion depth
--include PATTERNOnly show matching items
--exclude PATTERNHide matching items
--hash TYPEHash type for h format (e.g., MD5, SHA-1)

Practical Examples​

Scriptable File Listing​

# Get just filenames for a script
rclone lsf remote:uploads --files-only -R | while read -r file; do
echo "Processing: $file"
done

Generate File Inventory with Sizes​

# CSV-like output: size,path
rclone lsf remote:my-bucket -R --files-only \
--format "sp" --separator "," > inventory.csv

Find Files by Extension​

# List all SQL dumps
rclone lsf remote:backups -R --include "*.sql.gz"

# List all log files
rclone lsf remote:logs -R --include "*.log" --files-only

Compare Two Remotes​

# List files in both remotes and diff
rclone lsf remoteA:data -R --files-only | sort > /tmp/a.txt
rclone lsf remoteB:data -R --files-only | sort > /tmp/b.txt
diff /tmp/a.txt /tmp/b.txt

List Only Directories​

# Show directory structure
rclone lsf remote:my-bucket --dirs-only -R

lsf vs ls vs lsd​

Featurelsflslsd
Files✅ (default)✅❌
Directories✅ (default)❌✅
Recursive default❌✅❌
Custom format✅❌❌
Machine-readable✅PartiallyPartially
Best forScriptsInspectionStructure

Common Pitfalls​

PitfallConsequencePrevention
Forgetting --files-only in scriptsDirectories mixed with filesAdd --files-only when processing files
Default separator is ;Unexpected output with --formatSet --separator explicitly
Not recursive by defaultMisses files in subdirectoriesAdd -R for full listings

What's Next​

Examples with Output​

1. List only filenames for scripting​

Get a clean list of files without extra metadata. Command:

rclone lsf remote:bucket --files-only

Output:

file1.txt
image.jpg
data.csv

2. Generate CSV-style output (Size and Path)​

Custom format for use in spreadsheets or databases. Command:

rclone lsf remote:bucket --format "sp" --separator ","

Output:

1024,file1.txt
500000,image.jpg
123,data.csv

3. Recursive listing with full paths​

See everything in a machine-readable format. Command:

rclone lsf remote:bucket -R

Output:

folder1/
folder1/file_in_sub.txt
media/
media/logo.png
root_file.txt

4. Fetch MD5 hashes for files​

Verify integrity via custom format. Command:

rclone lsf remote:bucket --format "hp" --hash MD5

Output:

d41d8cd98f00b204e9800998ecf8427e;file1.txt
e4d909c290d0fb1ca068ffaddf22cbd0;image.jpg

5. List only directories with custom suffix​

Identify folders easily in automated scripts. Command:

rclone lsf remote:bucket --dirs-only --dir-slash=true

Output:

backups/
logs/
temp/