I'm trying to get the change time of a set of files in a folder. Everytime any archive changes, I need to autocreate a backup copy of the archives that have been last modified.
My tests:
I have tried the following code to get the date/time of chages and i need to list it to compare.
import os
import shutil
from pathlib import Path
import os.path, time
class edit:
def __init__(last_edit, chage, creation):
last_edit.change = list
last_edit.creation = list
file_soure = 'C:/Users/Automation/Desktop/NEW2/'
#file_destination = 'C:/Users/Automation/Desktop/NEW/'
get_files = os.listdir(file_source)
for x in range(2,len(get_files)):
last_edit.change = time.ctime(os.path.getmtime(x + get_files))
print(last_edit.change)
for g in get_files:
shutil.copy(file_source + g, file_destination)
Thats the result:
['Teste.txt', 'Teste2.txt']
Traceback (most recent call last):
File "c:\Users\Automação\Desktop\Scripts\Python\Teste.py", line 29, in <module>
print(last_edit.change)
NameError: name 'last_edit' is not defined
PS C:\Users\Automação\Desktop\Scripts\Python>
The object isnt declared?