1

Trying to run a script with Windows Task Scheduler to copy a folder to a different location on a schedule.

The script works, for ref:

import os
import shutil
import datetime

src = r'J:\SteamLibrary\steamapps\common\ARK\ShooterGame\Saved'

dest = r'J:\SteamLibrary\steamapps\common\ARK\ShooterGame\Saved\---BACKUP---'

x = datetime.datetime.now()

timestamp = x.strftime('%Y-%m-%d %H.%M.%S')

newdest = dest+'\\'+timestamp

ignore = shutil.ignore_patterns('---BACKUP---','*tmp')

shutil.copytree(src, newdest, ignore=ignore)

Not really looking for comments regarding this, as it does what I need, -unless- there's something I need to add to make it work correctly.

Now when I run the task through the console or by manually clicking "run" on the Task Scheduler, the folder generated has the timestamp of when the script runs.

However, when the task runs automatically based on the conditions of the task, ie - "run at 14:00", the folder it generates has a timestamp of a few days ago, presumably when I first generated the task itself - and every subsequent run of the task generated a folder with the identical date modified. See attached: https://i.stack.imgur.com/92HMJ.png

Any ideas on how to make the date modified of the folder created be the actual date created?

ancilla
  • 39
  • 5

0 Answers0