https://github.com/inspiaaa/python-file-library
  
  
    Python File Library is a collection of methods and classes to make working with files easier 
    https://github.com/inspiaaa/python-file-library
  
files filesystem folders oop python3 renaming
        Last synced: 8 months ago 
        JSON representation
    
Python File Library is a collection of methods and classes to make working with files easier
- Host: GitHub
- URL: https://github.com/inspiaaa/python-file-library
- Owner: Inspiaaa
- Created: 2019-06-09T08:45:43.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-10T21:34:10.000Z (over 6 years ago)
- Last Synced: 2025-01-12T12:20:11.750Z (10 months ago)
- Topics: files, filesystem, folders, oop, python3, renaming
- Language: Python
- Size: 22.5 KB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 0
- 
            Metadata Files:
            - Readme: README.md
 
Awesome Lists containing this project
README
          
  
# FL - Python File Library  
FL enables many **high level** operations on Files and Folders in an **OOP style**.
For example: *Flattening*, *Renaming*, *Recursively Moving* / *Copying* / *Deleting*, ...
  
## Getting Started
### Prerequisites
A working version of **Python 3.7**
---
### Example
#### Basic flattening of a folder
We create the folder structure:
```
example
├── a.txt
├── test
│   ├── b.txt
│   ├── temp
│   │   └── c.txt
```
... and want to **flatten** it to:
```
example
├── a.txt
├── b.txt
└── c.txt
```
We can achieve that with the following code:
```python
from fl import File, Folder, Example  
  
# Create the example nested folder structure with some files
Example.create_simple_nested()  
  
# Collapse (Flatten) the folder structure  
d = Folder("./example/")  
d.collapse()
```
---
### Adding the creation date to each file
Adding the **creation date** to all files in the folder:
```
example
├── a.txt
├── test
│   ├── a.txt
│   ├── b.txt
│   ├── temp
│   │   ├── a.txt
│   │   ├── b.txt
│   │   └── c.txt
```
To do this, we can run following program:
```python
from fl import File, Folder, Example
# Create the example folder structure: 
Example.create_nested_with_duplicates()
# Add the date
d = Folder("./example/")
d.rename_files("%B %TCd-%TCb-%TCY%E")
```
This program uses [special renaming commands](https://github.com/LavaAfterburner/Python-File-Library/wiki/Renaming-Commands) to add special data (e.g. Date). To **visualize** the result in the **console**, the folder class offers a method to print it:
```python
d = Folder("./example/")
d.print_beautified()
```
Console:
```
example
├── a 10-Jun-2019.txt
├── test
│   ├── a 10-Jun-2019.txt
│   ├── b 10-Jun-2019.txt
│   ├── temp
│   │   ├── a 10-Jun-2019.txt
│   │   ├── b 10-Jun-2019.txt
│   │   └── c 10-Jun-2019.txt
```
---
## Documentation
Get started with the documentation [here](https://github.com/LavaAfterburner/Python-File-Library/wiki).