filenumutils
Python tools to find last file/folder number in a int indexed file/folder with specified extension, prefix and/or suffix. Also allows to get/create next folder, e.g if dir contains train_00 and train_01, it creates train_02.
Installation
Simply install using pip
pip install filenumutils
Usage
Assuming the current working directory has the following structure
current_dir ├─ train_00 ├─ train_01 ├─ train_03 ├─ train_04 ├─ model_00.py ├─ model_01.py └─ model_02.py
Get Last Folder / File Number
from filenumutils import get_last_folder_number, get_last_file_number
get_last_folder_number(prefix="model_") # Output: 4
get_last_file_number(prefix="train_") # Output: 2
If no such file/folder with given prefix exists, it outputs -1
Get Next Folder / File Name
from filenumutils import get_next_file, get_next_folder
get_next_file(prefix="model_") # Output: model_03.py
get_next_folder(prefix="test_") # Output: test_00
get_next_folder(prefix="train_", create=True) # Output: train_05 (Folder is created)
If no such folder with given prefix exists, it outputs prefix_00.
Also, it will automatically stick to the existing numbering pattern.
For eg, if the folders were [train_0000, train_0001],
get_next_folder(prefix="train_", create=True) # Output: train_0000 (Folder is created)
More Options
| Attribute | Default | Description |
|---|---|---|
path |
Current Directory | Do operations in the given directory |
prefix |
"" | Match only files with given prefix |
suffix |
"" | Match only files with given extension/suffix |
default_number_width |
2 | When no numbering pattern is found, output number will be default_number_width digits |
full_path |
True | By default, returns new_folder_name. If True, returns path/new_folder_name. |
Contributing
Pull requests are very welcome.
- Fork the repo
- Create new branch with feature name as branch name
- Check if things work with a jupyter notebook
- Raise a pull request
Licence
Please see attached Licence
Metadata
Release files for filenumutils 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| filenumutils-0.1.2.tar.gz | 4.4 kB | Without provenance | Details for filenumutils-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| filenumutils-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for filenumutils-0.1.2-py3-none-any.whl |
Total release size: 9.2 kB
Release files / filenumutils-0.1.2.tar.gz
| Download URL | filenumutils-0.1.2.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
02cc266dafaa50973feff646f9884ffe53194ab392309625f293a9a03ceb1451
|
|
BLAKE2b-256 checksum How to use checksums |
ba707e2dfa66176089ef4e96805a9ad1f33d4b4ded2563c93d97d2e8d8545d57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
|
Release files / filenumutils-0.1.2-py3-none-any.whl
| Download URL | filenumutils-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e6261af08946f1d2a07ea231b966a20a719f241226e4cdbba944e30667d3314
|
|
BLAKE2b-256 checksum How to use checksums |
153106e32c633b6ee76c27d9ff34a2fe03e9182736af875fc5967e86803f022a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
|
Security for filenumutils 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.