Skip to content

Python File Library is a collection of methods and classes to make working with files easier

Notifications You must be signed in to change notification settings

Inspiaaa/Python-File-Library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 

Repository files navigation

Python 3.7

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:

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:

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 to add special data (e.g. Date). To visualize the result in the console, the folder class offers a method to print it:

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.

About

Python File Library is a collection of methods and classes to make working with files easier

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages