- Notifications
You must be signed in to change notification settings - Fork0
A class in Python to facilitate path management and file operations for common file-related tasks.
License
NotificationsYou must be signed in to change notification settings
spmohara/File-Manager
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A class to facilitate path management and file operations for common file-related tasks.
Methods can be split into the following groups:
- Path Validation (e.g., is_file, is_directory)
- Path Manipulation (e.g., path_join, get_file_extension)
- File Operations (e.g., create_file, delete_file)
- File Content Management (e.g., read_content, write_content)
- Directory Operations (e.g., create_directory, delete_directory)
fromfilemanagerimportFileManagerfile_manager=FileManager()
fromfilemanagerimportFileManagerfile_manager=FileManager(path='C:\\Users\\johndoe\\Documents')
- Gets the global path used for all methods.
file_manager.path
- Defines the global path used for all methods.
file_manager.path='C:\\Users\\johndoe\\Documents'
- Note: Allpath parameters are optional if using thepath attribute.
file_manager.is_file(path='C:\\Users\\johndoe\\Documents\\file.txt')
file_manager.is_directory(path='C:\\Users\\johndoe\\Documents')
file_manager.is_valid_path(path='C:\\Users\\johndoe')
- This method is primarily intended for validating path syntax, not existence (see path_exists method below).
file_manager.path_exists(path='C:\\Users\\johndoe\\Documents\\file.txt')
file_manager.path_join('C:\\Users\\johndoe\\Documents','file.txt')
file_manager.change_directory(path='C:\\Users\\johndoe')
file_manager.get_current_directory()
file_manager.get_parent_directory(path='C:\\Users\\johndoe\\Documents')
file_manager.get_base_name(path='C:\\Users\\johndoe\\Documents\\file.txt')
file_manager.get_file_extension(path='C:\\Users\\johndoe\\Documents\\file.txt')
file_manager.create_file(path='C:\\Users\\johndoe\\Documents\\file1.txt')
file_manager.rename_file(new_path='C:\\Users\\johndoe\\Documents\\file2.txt',path='C:\\Users\\johndoe\\Documents\\file1.txt')
file_manager.delete_file(path='C:\\Users\\johndoe\\Documents\\file2.txt')
file_manager.read_content(path='C:\\Users\\johndoe\\Documents\\file.txt')
file_manager.write_content(content='test1\n',path='C:\\Users\\johndoe\\Documents\\file1.txt')
file_manager.append_content(content='test2\ntest3\n',path='C:\\Users\\johndoe\\Documents\\file1.txt')
file_manager.read_line(path='C:\\Users\\johndoe\\Documents\\file1.txt')
file_manager.read_all_lines(path='C:\\Users\\johndoe\\Documents\\file1.txt')
file_manager.write_lines(lines=['test4\n','test5\n','test6\n'],path='C:\\Users\\johndoe\\Documents\\file1.txt')
file_manager.clear_file_content(path='C:\\Users\\johndoe\\Documents\\file1.txt')
file_manager.list_directory_contents(path='C:\\Users\\johndoe\\Documents')
file_manager.create_directory(path='C:\\Users\\johndoe\\Documents\\folder1')
file_manager.rename_directory(new_path='C:\\Users\\johndoe\\Documents\\folder2',path='C:\\Users\\johndoe\\Documents\\folder1')
file_manager.delete_directory(path='C:\\Users\\johndoe\\Documents\\folder2')
- Python 3.6 or above
Licensed under theMIT License
About
A class in Python to facilitate path management and file operations for common file-related tasks.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.