how to make directory on the google colab? I can not make the new directory on google driver on google colab?
how to make directory on the google colab? I can not make the new directory on google driver on google colab?
If you are looking for creating new folder in the 'Files' section (to the left from notebook) - you can run in code shell:
!mkdir new_folder
Just remember, that Colab is a temporary environment with an idle timeout of 90 minutes and an absolute timeout of 12 hours.
You can use !mkdir foldername command to create folder in the current working directory. It will be by default /content.
If you want to create directory with specific condition then use os.mkdir('folder_path') to create the directory.
import os.path
from os import path
if path.exists('/content/malayalam_keyphrase_extraction') == False:
os.mkdir('/content/malayalam_keyphrase_extraction')
os.chdir('/content/malayalam_keyphrase_extraction')
!pwd
!ls
or
!mkdir malayalam_keyphrase_extraction
NB: malayalam_keyphrase_extraction is the folder name
from google.colab import drive drive.mount('/content/drive')
mkdir "/content/drive/My Drive/name"
The way you want to do this is as follows:
from google.colab import drive
drive.mount('/content/gdrive')
os library. It has most of your typical bash commands which you can run right from your python script:import os
path = "gdrive/MyDrive/Rest/Of/Path"
os.mkdir(path)