I'm trying to find files which are 30 days old in a specific directory, move them to a new folder and compress that folder, however when I execute my script, Python complains about Python AttributeError: 'str' object has no attribute 'append'
import os
import time
import sys
import shutil
import tarfile
import sys
import os.path
import _strptime
from array import*
path="/Data/"
now = time.time()
export = os.path.join(path+"archives")
f=[]
m=[]
for root, dirs, files in os.walk(path): #List files in directory
for basename in files:
f.append(os.path.join(root,basename))
print(f)
for i in f:
mtime=os.stat(i).st_mtime
print(i, mtime)
if mtime > now - 7 * 86400:
m.append(i)
os.makedirs(export,0777)
for f in m:
print("moving file", f, "to", export)
shutil.move(f, export)
tarfile.open(export +time.strftime("%d-%Y-%m") +'.tar.gz', 'w:gz')
else:
print("Nothing to do")
appendto a string..append()on a string anywhere