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é

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!