google-colaboratory

How to change working directory in file-explorer UI in Google Colab?


Google Colab has a file-explorer UI pane on the left side.

How do I change the file-explorer on the left to simply "go down" into a folder?!?!?!?!?!?!

Or, how do I change the working directory in the file-explorer UI in Google Colab?

I can't find any relevant buttons or menu options. Nothing happens when I run the console command !cd /content. I've tried these 2 answers, to no avail. When I run %cd /content, the working directory of the console changes, but not the file explorer.

For example, suppose I accidentally click this button...

Oops

Now, my working directory is severely bloated, and it's not at all obvious that my previous directory is /content/.

Arrrrggggghhh!

How do I change it back?


Solution

  • I couldn't find a way to do it in UI other then refresh but below worked.

    from google.colab import files
    files.view('<dir path>')