D
David Fickbohm
People,
I am trying to determine the creation date of files in a folder.
I am using the following code to find the folder and confirm that files
exist in the folder. If someone could give me an idea how to check a
creation date it would be appreciated.
Thanks
dave
def delete_old_files (t:\dm\~\users)
# find files and delete files created more than XX number of days
ago
update_exist = 0
input_dir = t:\dm\~\users\xxxx.yyyyyy\zzzz
if os.path.exists (input_dir) :
files = os.listdir (input_dir)
else:
print "Unable to find input file dir: %s !!!" % input_dir
sys.exit(2)
if len(files):
for file in files :
file = os.path.join(input_dir) #all files in output
directory will be csv or xls, can be deleted if old enough
if os.path.isfile(file): #need to check ext not file, file
name changes each day
if re.search(t:\dm\~\users\xxxxx\) and #creation date
gt x number of days ago
t:\dm\~\users\davef.input_list.delete(file)
file_delete = 1
if file_delete:
print "\n file deleted: \n%s" %
str(t:\dm\~\users\xxxxx.input_list)
return file_delete
Dave Fickbohm
Data Mining Analyst
Homegain+
1250 45th St.
Emeryville, CA, 94608
Phone 510 594 4151 - Voice
510 655 0848 - Fax
I am trying to determine the creation date of files in a folder.
I am using the following code to find the folder and confirm that files
exist in the folder. If someone could give me an idea how to check a
creation date it would be appreciated.
Thanks
dave
def delete_old_files (t:\dm\~\users)
# find files and delete files created more than XX number of days
ago
update_exist = 0
input_dir = t:\dm\~\users\xxxx.yyyyyy\zzzz
if os.path.exists (input_dir) :
files = os.listdir (input_dir)
else:
print "Unable to find input file dir: %s !!!" % input_dir
sys.exit(2)
if len(files):
for file in files :
file = os.path.join(input_dir) #all files in output
directory will be csv or xls, can be deleted if old enough
if os.path.isfile(file): #need to check ext not file, file
name changes each day
if re.search(t:\dm\~\users\xxxxx\) and #creation date
gt x number of days ago
t:\dm\~\users\davef.input_list.delete(file)
file_delete = 1
if file_delete:
print "\n file deleted: \n%s" %
str(t:\dm\~\users\xxxxx.input_list)
return file_delete
Dave Fickbohm
Data Mining Analyst
Homegain+
1250 45th St.
Emeryville, CA, 94608
Phone 510 594 4151 - Voice
510 655 0848 - Fax