-
-
Notifications
You must be signed in to change notification settings - Fork 102
Programming: Useful file tools in Python
Joshua Newton edited this page Jan 2, 2021
·
3 revisions
Most file commands can be found here and here
-
cp filename path
-->shutil.copy(filename, path)
-
rm -rf path
-->shutil.rmtree(path, ignore_errors=True)
-
mv filepath1 filepath2
-->shutil.move(filepath1, filepath2)
-
Note: Do not use
os.rename
! Instead, useshutil.move
for this too, becauseos.rename
has an issue that causes problems withtmp_path
on CI, as well as any users who have files spread across different filesystems.
-
Note: Do not use
-
status, path_sct = commands.getstatusoutput('echo $SCT_DIR')
-->path_sct = os.environ.get('SCT_DIR')
Editing the Wiki? If you're adding a new page or changing a title, be sure it fits the existing Wiki Structure.