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.
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:
| Character | Field | Example |
|---|---|---|
p | Path (default) | documents/report.pdf |
s | Size (bytes) | 12345 |
t | Modification time | 2024-01-15 10:30:00 |
h | Hash | d41d8cd98f00b204e9800998ecf8427e |
i | ID (backend-specific) | abc123 |
o | Original (backend-specific) | varies |
m | MIME type | application/pdf |
e | Encrypted 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
| Flag | Description |
|---|---|
-R / --recursive | List recursively |
--format FORMAT | Output field format string |
--separator SEP | Field separator (default ;) |
--dir-slash | Show trailing / on directories (default true) |
--dirs-only | Show only directories |
--files-only | Show only files |
--max-depth N | Limit recursion depth |
--include PATTERN | Only show matching items |
--exclude PATTERN | Hide matching items |
--hash TYPE | Hash 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
| Feature | lsf | ls | lsd |
|---|---|---|---|
| Files | ✅ (default) | ✅ | ❌ |
| Directories | ✅ (default) | ❌ | ✅ |
| Recursive default | ❌ | ✅ | ❌ |
| Custom format | ✅ | ❌ | ❌ |
| Machine-readable | ✅ | Partially | Partially |
| Best for | Scripts | Inspection | Structure |
Common Pitfalls
| Pitfall | Consequence | Prevention |
|---|---|---|
Forgetting --files-only in scripts | Directories mixed with files | Add --files-only when processing files |
Default separator is ; | Unexpected output with --format | Set --separator explicitly |
| Not recursive by default | Misses files in subdirectories | Add -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/