Drupal is a registered trademark of Dries Buytaert
Release: Leaflet 10.4.11 Minor update available for module leaflet (10.4.11). Release: Session Inspector 1.0.8 Minor update available for module session_inspector (1.0.8). Release: Migrate QA 2.0.4 Minor update available for module migrate_qa (2.0.4). Release: CKEditor Description List 3.0.0 Major update available for module ckeditor_descriptionlist (3.0.0). Release: FlowDrop 2.4.0 Minor update available for module flowdrop (2.4.0). Release: JWT Token Refresh 1.0.4 Minor update available for module jwt_token_refresh (1.0.4). Release: ConReg 1.0.0-beta1 First beta version released for module conreg (1.0.0-beta1). Release: AI Image Studio 1.0.0-beta8 New beta version released for module ai_image_studio (1.0.0-beta8). Usage Milestone: Statistics Counter Module statistics_counter crossed 1,000 active installs. Module Revived: Decoupled Router 2.0.7 Module decoupled_router updated after 11 months of inactivity (2.0.7).

File System to Cli

3 sites Security covered
View on drupal.org

This module provides Drush commands to manage files in Drupal, allowing you to inspect and manipulate them from the command line. It works with Drupal's stream wrappers, supporting various storage locations like local disk or S3, and outputs results in machine-readable JSON for automation.

File System to CLI (fs_cli)

File System to CLI exposes Drupal's file system API as a small set of Drush commands, so you can inspect and manipulate files from the command line and from automation.

Every command runs through Drupal's file_system service rather than touching the disk directly. That means operations honor Drupal stream wrappers: public://, private://, temporary://, and remote backends such as s3:// (via the S3 File System module). A script behaves the same whether the files live on local disk or in object storage.

Each command returns machine-readable JSON. This makes the module a good fit for deployment pipelines, CI jobs, and infrastructure tooling that needs to act on the result of a file operation without writing custom PHP.

Requirements

  • Drupal 10 or 11.
  • Drush 12 or newer.

Installation

Install with Composer, then enable the module:

composer require drupal/fs_cli
drush pm:enable fs_cli

No configuration is required.

Commands

Command Alias Description fs:file-exists fs-fe Report whether a file exists. fs:directory-exists fs-de Report whether a directory exists. fs:copy [replace] Copy a file, creating the destination directory if needed. fs:move [replace] Move a file, creating the destination directory if needed. fs:mkdir Create a directory. fs:scan-dir List the files in a directory that match a regular-expression mask. fs:delete-dir Delete a directory and its contents recursively.

All commands accept a --format option (default json).

For fs:copy and fs:move, the optional replace argument controls what happens when the destination already exists:

  • 0 — rename: append an incrementing numeric suffix until the name is unique.
  • 1 — replace the existing file (default).
  • 2 — do nothing and return an error.

Examples

# Check whether a file exists on the public file system.
drush fs:file-exists public://logo.png

# Copy a file to S3-backed storage (with S3 File System configured).
drush fs:copy public://export.csv s3://backups/export.csv

# List every JPEG file under a directory.
drush fs:scan-dir public://images '/\.jpg$/'

# Create a working directory and remove it afterwards.
drush fs:mkdir temporary://build
drush fs:delete-dir temporary://build

Maintainers

  • Marco Primitivo (Bladedu)

Sponsored by SparkFabrik.

Activity

Tracked releases
1
Tracked since
Jun 2026
Latest release
1 month ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Release date
1.0.0 Stable Jun 26, 2026