Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving files in Google Colab

I have I bunch of files in a directory, named like this:

cat.10171.jpg cat.12421.jpg cat.3421.jpg

I want to move part of them to another directory using this from Colab notebook:

!mv cat.{0..499}.jpg /content/train

I have an error:

mv: cannot stat 'cat.{0..499}.jpg': No such file or directory

Any ideas how to do this and what is the reason?

like image 332
Kate Lyapina Avatar asked Jun 29 '18 22:06

Kate Lyapina


People also ask

How do I transfer files from Google Colab?

Click on “Choose Files” then select and upload the file. Wait for the file to be 100% uploaded. You should see the name of the file once Colab has uploaded it. Finally, type in the following code to import it into a dataframe (make sure the filename matches the name of the uploaded file).

Can Google colab save file to drive?

Working with Google SheetsColab allows you to save your work to Google Drive or even directly to your GitHub repository.

Can Google colab access local folders?

Colaboratory lets you connect to a local runtime using Jupyter. This allows you to execute code on your local hardware and have access to your local file system.


1 Answers

This also worked for me:

shutil.move("path/to/current/file", "path/to/new/destination/for/file")

So:

shutil.move("/content/cat.10171.jpg", "/content/train") 
like image 200
Avocano Avatar answered Oct 16 '22 20:10

Avocano