Skip to content

Simple, convenient and cross-platform file date changing library. πŸ“…

License

Notifications You must be signed in to change notification settings

kubinka0505/filedate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

γ€€

γ€€γ€€

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,
)