Ali Mojiz
Ali Mojiz

Reputation: 21

Change folder name in Databricks File System

Have some data stored in different directory paths in databricks file system. Need to rename some folders. Is it possible to rename folders in DBFS? If so, what's the command?

Upvotes: 2

Views: 12677

Answers (2)

Palash Mondal
Palash Mondal

Reputation: 538

Use this. Just replace the path with your actual path.

old_name = r"dbfs:/FileStore/tables/PM/TC/ROBERTA"
new_name = r"dbfs:/FileStore/tables/PM/TC/BERT"

dbutils.fs.mv(old_name, new_name, True)

Upvotes: 2

Andreas Storvik Strauman
Andreas Storvik Strauman

Reputation: 1655

You can use mv with %fs magic, or dbutils.fs to do this. This command is used for renaming and/or moving files and directories

%fs mv -r /path/to/folder /path/to/new_folder_name

the -r is to do recursive move with directories.

It's documented in the dbutils. There is also more info here.

Upvotes: 2

Related Questions