Size: 1665
Comment:
|
Size: 1712
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 9: | Line 9: |
== ChOwn == | == Usage == === ChOwn === |
Line 15: | Line 17: |
== Copy == | === Copy === |
Line 38: | Line 40: |
== Copy2 == | === Copy2 === |
Line 46: | Line 48: |
== CopyFile == | === CopyFile === |
Line 69: | Line 71: |
== CopyMode == | === CopyMode === |
Line 75: | Line 77: |
== CopyStat == | === CopyStat === |
Line 81: | Line 83: |
== CopyTree == | === CopyTree === |
Line 87: | Line 89: |
== Disk_Usage == | === Disk_Usage === |
Line 93: | Line 95: |
== Get_Archive_Formats == | === Get_Archive_Formats === |
Line 99: | Line 101: |
== Get_Terminal_Size == | === Get_Terminal_Size === |
Line 105: | Line 107: |
== Get_Unpack_Formats == | === Get_Unpack_Formats === |
Line 111: | Line 113: |
== Make_Archive == | === Make_Archive === |
Line 117: | Line 119: |
== Move == | === Move === |
Line 123: | Line 125: |
== RmTree == | === RmTree === |
Line 129: | Line 131: |
== Unpack_Archive == | === Unpack_Archive === |
Line 135: | Line 137: |
== Which == | === Which === |
Python ShUtil
Contents
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
Python shutil module documentation