'Set folder timestamp with Python

I'm writing a script that processes files in directories, but I want the directories' timestamps to remain the same. So I want to get the timestamp before the operation, then set in back after.

Getting the timestamp is easy enough (os.path.getmtime()), but I can't seem to find an equivalent set method.

Any suggestion?



Solution 1:[1]

use os.utime().

Should work fine.

Define variables with date, time and stuff before so the actual setting function doesn't get that cluttered.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sabri_1