Changing directory in google colab from google drive

Viewed 18

Cutting to the chase so i wanted to change my directory for my working environtment and i've been wondering a little bit

if i restart my runtime and type

drive.mount('/content/gdrive/', force_remount=True)
%cd gdrive/MyDrive/Laporan/Skripsi/Data

this works, but if i haven't mount my drive and do this instead

drive.mount('/content/gdrive/', force_remount=True)
%cd gdrive/MyDrive/Laporan/Skripsi
%cd gdrive/MyDrive/Laporan/Skripsi/Data

This gave me an error saying "[Errno 2] No such file or directory: 'gdrive/MyDrive/Laporan/Skripsi/Data' /content/gdrive/MyDrive/Laporan/Skripsi"

and of course this makes sense since i'm at the folder Skripsi already, so how do i go back to the directory before? (example i'm already at Data and wanted to go to Skripsi)

i am new to python and i only import the

from google.colab import drive

do i need to use the library "os" to do so? if yes how to?

0 Answers
Related