anybody know how to set the creation date of a file in python?

(currently moving my journal from DayOne to markdown files and I would like to set the creation date of the file to the original creation)

@ploum I imagine you want to stay crossplateform therefore you can't use a subprocess "touch" with the right arguments ?

@ronane : I don't really care about crossplatform. Unix only is fine (should work on Linux and macOS)

@ploum I'm not sure there is any way doing what you wan't without using some nasty tricks like changing your sysdate when you create (the file or change its perms (chmod)


I think there's no direct way to do it

ps: you can set mtime in Python with os.utime() and flip a permission bit with os.chmod()

hope this helps

Sign in to participate in the conversation
La Quadrature du Net - Mastodon - Media Fédéré

Bienvenue dans le media fédéré de la Quadrature du Net association de défense des libertés. Les inscriptions sont ouvertes et libres.
Tout compte créé ici pourra a priori discuter avec l'ensemble des autres instances de Mastodon de la fédération, et sera visible sur les autres instances.
Nous maintiendrons cette instance sur le long terme.