/kubinka0505-filedate

Simple, convenient and cross-platform file date changing library. 📅

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

Description 📝

Simple, convenient and cross-platform file date changing library. 📅

Installation 🖥️

  1. git (recommended)
git clone git://github.com/kubinka0505/filedate
cd filedate/Files
python setup.py install
  1. pip
python -m pip install filedate

Usage 📝

import filedate

# Create filedate object
File_Date = filedate.File("~/Desktop/File.txt")

# Get file date
File_Date.get()

# Set file date
File_Date.set(
	created = "01.01.2000 12:00",
	modified = "3:30PM 2001/02/02",
	accessed = "3rd March 2002 20:00:30"
)

Copy file dates from one to another 🔃

from filedate.Utils import Copy
Copy("~/Desktop/Input.mp4", "~/Desktop/Output.mp4").all()

Keeping files dates

from pathlib import Path
from filedate import Utils

# Get all files in subdirectories (recursive!)
Files = []
for File in Path(".").glob("**/*"):
	Files.append(File)

#---#

# Initialize `Keep` object
Dates = Utils.Keep(Files)

# Pick dates
Dates.pick()

# ... Do your stuff ...
#
# from os import system
# for File in Files:
#     system(f'optimize -i "{File}"')

# Drop dates
Dates.drop()

Set file dates based on its name 📝

from filedate.Utils import Name

# Sets creation date
Name("~/Downloads/20200919_134705.wav").created()

# Sets all file dates
Name("Recording_20010204_103503.mp3").all()