Skip to content

Instantly share code, notes, and snippets.

@zhuguoliang
Last active February 7, 2024 04:00
Show Gist options
  • Save zhuguoliang/4a65f25675fb215e8bbe8fa92a5bb88c to your computer and use it in GitHub Desktop.
Save zhuguoliang/4a65f25675fb215e8bbe8fa92a5bb88c to your computer and use it in GitHub Desktop.
colab list folders
import os
# files = os.listdir('/content/drive')
# for fname in files:
# print (fname)
# print ('full path', os.path.join(os.getcwd(), fname))
def list_files(startpath):
for root, dirs, files in os.walk(startpath):
level = root.replace(startpath, '').count(os.sep)
indent = ' ' * 4 * (level)
print('{}{}/'.format(indent, os.path.basename(root)))
subindent = ' ' * 4 * (level + 1)
for f in files:
print('{}{}'.format(subindent, f))
list_files('/content/drive/MyDrive/nus-cs4248x/3-neural-nlp/data/corpora')
from google.colab import drive
drive.mount('/content/drive')
import os
os.chdir ("/content/drive/MyDrive/nus-cs4248x/3-neural-nlp/")
print(os.getcwd())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment