= Python ShUtil = <> ---- == Usage == === ChOwn === ---- === Copy === Copy the contents of a file to another file (or directory). File permissions are also copied. {{{ from pathlib import Path import shutil p = Path('.') original = p.joinpath('build') destination = p.joinpath('archive') for f in original.iterdir(): shutil.copy(f, destination) }}} If the source and destination filenames represent the same file, `shutuil.SameFileError` is raised. If the destination is not writeable, `OSError` is raised. ---- === Copy2 === Same as `copy` but tries to preserve metadata. ---- === CopyFile === Copy the contents of a file to another file. No metadata is copied. {{{ from pathlib import Path import shutil p = Path('.') original = p.joinpath('build') destination = p.joinpath('archive') for f in original.iterdir(): shutil.copyfile(f, destination.joinpath(f.name)) }}} If the source and destination filenames represent the same file, `shutuil.SameFileError` is raised. If the destination is not writeable, `OSError` is raised. ---- === CopyMode === ---- === CopyStat === ---- === CopyTree === ---- === Disk_Usage === ---- === Get_Archive_Formats === ---- === Get_Terminal_Size === ---- === Get_Unpack_Formats === ---- === Make_Archive === ---- === Move === ---- === RmTree === ---- === Unpack_Archive === ---- === Which === ---- == See also == [[https://docs.python.org/3/library/shutil.html|Python shutil module documentation]] [[https://pymotw.com/3/shutil/|Python Module of the Day article for shutil]] ---- CategoryRicottone