I have a file Locations.txt
which has contents:
Type Dir1 Dir2 Dir3 Dir4
Music D:\files1\music D:\files2\music D:\files3\music D:\files4\music
Docs E:\files1\doc D:\files2\doc D:\files3\doc D:\files4\doc
Where Type is the type of file and Dir1-4 are directories where specific music and doc files are stored. Everyday files get added to these folders.
What I tried is:
import fileinput
lDir=[]
def getFiles():
fname= 'D:\server_logs\locations.txt'
for line in fileinput.input([fname], openhook=fileinput.hook_compressed):
if "Dir1 Dir2 Dir3 Dir4" in line:
continue
else:
lDir.append(line)
for l in lDir:
print l
"""
Now first I want to display Music files that were added yesterday in these directories
Add all new files of Music type and pass the latest files to another function to process further
func2(*list_of_new_files*)
After this func2 is processed I want all Latest Docs Files to pass to func2()
"""
def modification_date(filename):
t = os.path.getctime(filename)
return datetime.datetime.fromtimestamp(t)
//Othe LOC
for root, dirs, files in sorted(os.walk("D:\\files1\\music")):
appnm="Music"
if appnm == root.split("\\")[-1] and len(files)>0:
for file in files:
if file.endswith(".mp3"):
file_created_time = modification_date(root+'\\'+file)
if file_created_time :
file_path= os.path.join(root, file)
my_files.append(file_path)
///
getFiles()
I need to pass the path fetched from the file in os.walk.