0

I can't believe this hasn't been asked before. I've googled with all queries and quotes and found no result. How the heck can I copy a folder inside jupyter notebook? Like, the whole folder, not just the path, or the files one by one, but the whole folder.

Thanks.

chris_smith
  • 1
  • 1
  • 1

2 Answers2

1

You can run shell commands from jupyter notebooks using the exclamation mark in front of the command, e.g.

!cp -r /path/to/src /path/to/dest
Carlos Horn
  • 1,115
  • 4
  • 17
0

You can just do it like the usual python script.

Here's a solution I found from another question:

from distutils.dir_util import copy_tree
copy_tree("/a/b/c", "/x/y/z")

How do I copy an entire directory of files into an existing directory using Python?

Zheng Bowen
  • 339
  • 2
  • 7
  • This raises a FileNotFoundError for me in Jupyter, but not in a regular Python interpreter. – dcafdg Aug 25 '22 at 22:29
  • I need the same, but for students (we use JupyterHub) for which a graphical "widget" would be a better solution... any idea ? – Antonello Jan 24 '23 at 10:29