File Functions

betterfunctions.filefunctions.create_directory(name)

Creates a new directory.

Parameters:

name (str) – The name of the new directory.

betterfunctions.filefunctions.create_text_file(text, directory=None, filename='file.txt')

Creates a text file in a directory with given name and given text.

Parameters:
  • directory (str | None) – The directory where the file should be created. Default’s to None.

  • text (str) – The text, which should be in the created file.

  • filename (str) – The name of the created file.

betterfunctions.filefunctions.delete_file(file_path)

Deletes a file.

Parameters:

file_path (str)

betterfunctions.filefunctions.file_size(file_path, size_type='KB')

Returns the size of a file.

Parameters:
  • file_path (str) – The path of the file.

  • size_type (str) – The size type in which the result should be displayed. Defaults to KB.

Return type:

str

betterfunctions.filefunctions.list_files_in_directory(directory)

Lists all files in a given directory.

Parameters:

directory (str) – The directory from which the items should be displayed.

Return type:

list