Python Module shutil

From NovaOrdis Knowledge Base
Revision as of 20:21, 2 March 2022 by Ovidiu (talk | contribs)
Jump to navigation Jump to search

External

Internal

Overview

The shutil module offers high-level operations on files and collections of files. In particular, functions are provided which support file copying and removal. For operations on individual files, see also the os module.

Recursively Copy a Directory

import shutil

shutil.copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2, ignore_dangling_symlinks=False, dirs_exist_ok=False)

Organizatorium

from shutil import which
for i in m:
  print("{:20}{:7}".format(m[i], "OK" if which(i) else "missing"))