In this memo I'll save some common methods related to shutil, move2trash modules and some more from os module.
shutil.
import shutil
shutil.copy('source', 'destination') - copies file or directory
shutil.copytree('source', 'destination') - copies directory with all subdirectories & files
shutil.move('source', 'destination') - moves file or directory
shutil.remtree(path) - remove directory with all subdirectories
send2trash.
import send2trash
send2trash.send2trash(path) - moves file or directory to the bin
os.
import os
os.walk(path) - returns list of all directories, subdirectories and files
os.unlink(path) - permanently deletes file
os.rmdir(path) - permanently removes directory
No comments:
Post a Comment