A simple Python library for folder and file manipulation using an object-oriented approach.
You can install this library locally by running the following command in the root directory (my_folder_lib/):
pip install -e .
from fm import FM
# Create an instance of FM
fm = FM()
# Create a folder
fm.create_folder("my_directory")
# List files in the folder (optionally filter by extension)
files = fm.list_files("my_directory", extension_filter=".txt")
print(files)
# Copy a file
fm.copy_file("source.txt", "destination.txt")
# Move a file
fm.move_file("destination.txt", "new_location.txt")
# Rename a file or folder
fm.rename("old_name.txt", "new_name.txt")
# Check if a file or folder exists
exists = fm.exists("my_directory")
print(exists)
# Get detailed information about a file
info = fm.get_file_info("source.txt")
print(info)
# Delete a folder
fm.delete_folder("my_directory")- Create folders
- Delete folders
- List files in a folder with optional extension filtering
- Copy files
- Move files
- Rename files or folders
- Check existence of files or folders
- Get detailed file information (size, creation date, modification date)
- Python 3.6 or higher
To push this library to a remote Git repository (e.g., GitHub):
-
Create a new repository on GitHub or your preferred Git hosting service.
-
Run the following commands in the
my_folder_lib/directory:git remote add origin <repository-url> git branch -M main git push -u origin mainReplace
<repository-url>with the URL of your remote repository.
To publish this library to PyPI so others can install it via pip:
-
Ensure you have the necessary tools installed:
pip install build twine -
Build the distribution packages:
python -m build -
Upload to PyPI (you'll need a PyPI account and API token):
python -m twine upload dist/*Follow the prompts to enter your PyPI credentials or API token.
After publishing, users can install your library with:
pip install folder-utils