A chronological folder backup script for those who want flexibility.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.4 KiB

import os
import datetime
class Chronologics:
Handles creation of chronological folders
destination: string (from class Chronos)
def __init__(self, destination):
self.destination = destination
def _get_date(self):
# Returns tuple of numeric values of now()
time = datetime.datetime.now()
year = time.year
month = time.month
day = time.day
hour = time.hour
minute = time.minute
second = time.second
return (year, month, day, hour, minute, second)
def _create_paths(self, current_time):
# Returns a tuple of the concatenated paths in
# chronological order. It looks like:
# ('year', 'year/month', 'year/month/day')
return (
def paths(self):
return self._create_paths(self._get_date())
def _create_folder(self, name):
os.mkdir(os.path.join(self.destination, str(name)))
except FileExistsError:
def _create_all_folders(self):
for time in self.paths:
def _create_chronological_folders(self):
current_time = self._get_date()
return f'{self.destination}/{self.paths[2]}' # returns the final destination
def init(self):
path = self._create_chronological_folders()
return path
def __call__(self):
return self.init()