I have an existing automation that picks up "today's" file from a network drive, loads them locally on C drive, then loads the data from that files.
Each file has the same file name, but with the date added at the end. For example, FileName_20220315
. How can I edit my existing automation to run every file, one after the other or one at a time between a past date to today or the last one?
For example...
- Runs
FileName_20220301
. - Once completed, picks up the next file,
FileName_20220302
. - And continues until the last file.
import time, glob, os, pysftp, datetime
from shutil import copyfile
from Utils.Utilities import Utilities
import win32com.client as win32
from datetime import date
from email.mime.multipart import MIMEMultipart
from email.mime.application import MIMEApplication
from email.mime.text import MIMEText
global Status, log_file_name, user_file_name, team_file_name
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
import mimetypes, smtplib
Status = ""
log_file_name = ""
today = date.today().strftime("%Y%m%d")
#today=20211122
now = datetime.datetime.now()
today_date_time = ('%s_%s_%s_%s_%s' % (now.month, now.day, now.year, now.hour, now.minute))
import getpass
user = getpass.getuser().lower()
count = 30
Email_count = 0
file_name = "File_Name_%s.csv" % (today)