pythonpython-2.7appiumappium-iospython-appium

How to change the creation date of file using python on a mac?


I need to update the creation time of a .mp4 file so that it will appear at the top of a list of media files sorted by creation date. I am able to easily update both the accessed and modified date of the file using os.utime, but have yet to find a good way to change the created date of a file to "now".

My end goal is to seed media files to an iOS simulator using appium, and have those media files accessible in that script. The issue is that the video file will not be displayed in the "recently added" section of the app because it is several days old.


Solution

  • I was able to successfully use the subprocess call command to change the creation date of the file with a shell command.

    from subprocess import call
    
    command = 'SetFile -d ' + '"05/06/2019 "' + '00:00:00 ' + complete_path
    call(command, shell=True)