Folder
Folder module for autopylot. This module contains functions for working with folders and files.
Examples:
>>> from autopylot import folder
>>> folder.create_folder(path='tests\demo')
>>> folder.delete_folder(path='tests\demo')
It contains the following functions:
- is_folder(path): Returns True if the given path is a folder.
- 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, only_contents=False)
  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 | 
only_contents | 
          
                bool
           | 
          If True, only the contents of the folder will be copied. Default is False.  | 
          
                False
           | 
        
Returns:
| Type | Description | 
|---|---|
                None
           | 
          None  | 
        
Examples:
create_folder(path)
  
delete_folder(path)
  
get_contents(path, extension='all')
  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 | 
extension | 
          
                str
           | 
          The extension of the files to return. Default is "all".  | 
          
                'all'
           | 
        
Returns:
| Name | Type | Description | 
|---|---|---|
contents |           
                list
           | 
          A list of all files and folders in the folder.  | 
        
Examples:
get_contents_recursive(path, extension='all')
  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 | 
extension | 
          
                str
           | 
          The extension of the files to return. Default is "all".  | 
          
                'all'
           | 
        
Returns:
| Name | Type | Description | 
|---|---|---|
contents |           
                list
           | 
          A list of all files and folders in the folder and all subfolders.  | 
        
Examples:
get_size(path)
  
get_size_human(path)
  
is_folder(path)
  Returns True if the given path is a folder.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
path | 
          
                str || Windows Path
           | 
          Path of the folder.  | 
          required | 
Returns:
| Type | Description | 
|---|---|
                bool
           | 
          Is Folder (bool): True if the given path is a folder, False otherwise.  | 
        
Examples:
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 | 
Returns:
| Type | Description | 
|---|---|
                None
           | 
          None  | 
        
Examples:
rename_folder(path, new_name)
  Rename a folder at the given path.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
path | 
          
                str || WindowsPath
           | 
          The path to the folder.  | 
          required | 
new_name | 
          
                str
           | 
          The new name of the folder.  | 
          required | 
Returns:
| Type | Description | 
|---|---|
                None
           | 
          None  | 
        
Examples: