Folder
Folder module for dost. This module contains functions for working with folders and files.
Examples:
>>> from dost import folder
>>> folder.create_folder(path='tests\demo')
>>> folder.delete_folder(path='tests\demo')
It contains the following functions:
create_folder(path)
: Create a folder at the given path.delete_folder(path)
: Delete a folder at the given path.rename_folder(path, new_name)
: Rename a folder at the given path.copy_folder(source, destination)
: Copy a folder from the source to the destination.move_folder(source, destination)
: Move a folder from the source to the destination.get_size(path) -> int
: Get the size of a folder in bytes.get_size_human(path) -> str
: Get the size of a folder in human readable format.get_contents(path) -> list
: Get a list of all files and folders in a folder.get_contents_recursive(path) -> list
: Get a list of all files and folders in a folder and all subfolders.
copy_folder(source, destination)
Copy a folder from the source to the destination.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
str || WindowsPath
|
The path to the source folder. |
required |
destination |
str || WindowsPath
|
The path to the destination folder. |
required |
Examples:
create_folder(path)
delete_folder(path)
get_contents(path)
Get a list of all files and folders in a folder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str || WindowsPath
|
The path to the folder. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
A list of all files and folders in the folder. |
Examples:
get_contents_recursive(path)
Get a list of all files and folders in a folder and all subfolders.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str || WindowsPath
|
The path to the folder. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
A list of all files and folders in the folder and all subfolders. |
Examples:
get_size(path)
get_size_human(path)
move_folder(source, destination)
Move a folder from the source to the destination.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
str || WindowsPath
|
The path to the source folder. |
required |
destination |
str || WindowsPath
|
The path to the destination folder. |
required |
Examples: