!!! info "Enable Folder Listing"
By default, the `ls` command does not display folders. To enable folder listing, run the following command:
```
fab config set folder_listing_enabled true
```
This page demonstrates how to manage folders in Microsoft Fabric using the CLI. Folder operations allow you to organize items and resources within workspaces and supported item types.
!!! note "Resource Type"
Type: .Folder
To explore all folder-related commands and their parameters, run:
fab desc .Folder
Navigate to a folder using the full workspace path.
fab cd ws1.Workspace/fd1.Folder
Navigate to a workspace using relative path from current context.
fab cd ../../ws1.Workspace/fd1.Folder
Create a new folder within a workspace.
fab create ws1.Workspace/fd1.Folder
Check if a folder exists.
fab exists ws1.Workspace/fd1.Folder
Retrieve full folder details.
fab get ws1.Workspace/fd1.Folder
Query folder properties using JMESPath syntax.
fab get ws1.Workspace/f1.Folder -q id
Save query results to a local file.
fab get ws1.Workspace/fd1.Folder -q parentFolderId -o /tmp
List the workspace contents. This command returns both items and folders within the workspace.
fab ls ws1.Workspace
List the contents of a folder. Use -l for detailed output.
fab ls ws1.Workspace/fd1.Folder
Set or update folder properties (currently only displayName is supported). Use -f to force updates.
fab set ws1.Workspace/fd1.Folder -q displayName -i fd1ren
Remove a folder. Use -f to force deletion without confirmation.
fab rm ws1.Workspace/fd1.Folder
The folder is copied to the root of the destination workspace, preserving its name. This will fail if a folder with the same name already exists.
fab cp source.Workspace/source.Folder target.Workspace
Result: target.Workspace/source.Folder
-
If the destination folder exists, the source folder is copied inside it.
fab cp ws.Workspace/source.Folder ws.Workspace/dest.FolderResult:
ws.Workspace/dest.Folder/source.Folder -
If the destination folder does not exist, the source folder is renamed to the destination folder name.
fab cp ws.Workspace/source.Folder ws.Workspace/dest.FolderResult:
ws.Workspace/dest.Folder
Move folder to workspace, preserving its name.
!!! warning "This command will fail if a folder with the same name already exists"
fab mv ws1.Workspace/source.Folder ws2.Workspace
-
If the destination folder does not exist, the source folder is renamed to the destination folder name.
fab mv ws1.Workspace/source.Folder ws2.Workspace/dest.FolderResult:
ws2.Workspace/dest.Folder -
If the destination folder exists, the source folder is moved inside it.
fab mv ws1.Workspace/source.Folder ws2.Workspace/dest.FolderResult:
ws2.Workspace/dest.Folder/source.Folder
Deploy specific folders from local content using configuration files. This allows selective deployment of folder contents.
Deploy only items within specific folders to target workspace.
fab deploy --config config.yml -tenv dev -P config_override='{"publish": {"folders_to_include": ["Production", "Core"]}, "features": ["enable_include_folder", "enable_experimental_features"]}'
Deploy workspace content while excluding specific folders.
fab deploy --config config.yml -tenv prod -P config_override='{"publish": {"folder_exclude_regex": "^temp|^debug"}, "features": ["enable_exclude_folder", "enable_experimental_features"]}'
!!! note "Configuration Options"
All the configuration options shown above with config_override can also be defined directly in the configuration file instead of passing them as command-line overrides. The config_override examples are provided for demonstration and dynamic configuration purposes.
For managing folders within OneLake storage (e.g., Lakehouse/Files), see OneLake Examples