Skip to content

Latest commit

 

History

History
123 lines (96 loc) · 3.19 KB

ReadMe.md

File metadata and controls

123 lines (96 loc) · 3.19 KB

 

  

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

Tip

You can alse use this ugly one-liner for most recent commits:

python -m pip install "git+https://github.com/kubinka0505/filedate#egg=filedate&subdirectory=Files" -U --use-deprecated=legacy-resolver
  1. pip
python -m pip install filedate -U

Usage 📝

import filedate

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

# Get file date
File.get_dates()

# Alternatives
dir(File)
File.created, File.modified, File.accessed

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

# Legacy
File.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 🔃
import filedate

filedate.copy(
    "~/Desktop/Input.mp4", "~/Desktop/Output.mp4",
    created = True,
    modified = True,
    accessed = True
)
Keeping files dates
import filedate
from pathlib import Path

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

#-=-=-=-#

# Initialize `Keep` object
dates = filedate.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 (beta) 📝
from filedate import utils

utils.set_from.file_name(
    "~/Downloads/20200919_134705.wav",
    created = True,
    modified = False,
    accessed = True,
)