#Auther: lancer
#Data: 2011-6-7
#Function: Get name of all media files from folder and process it, then write to another file as array format.
#Version: 1.00
#read files from media folder and compose to list
list_files = os.listdir(media_path)
#cmd = "dir /A-D /B"
#list_file = os.popen(cmd).readlines();
#print list_files
for folder in list_files:
if folder=='sound' or folder=='music' or folder=='video':
#print "found path:"+folder
process_folder(folder)
else:
print "useless folder: " + folder
#for line in code_array_list:
#print line
file_to_write = 'temp.txt'
ignore_input = False
#open code file that include sound list and replace it
readf = file(to_process_file, 'r') # open for read
writef = file(file_to_write, 'w') # open for write
while True:
line = readf.readline()
if len(line) == 0: # Zero length indicates EOF
break
#print line,
if not ignore_input:
writef.write(line) # write text to file
if re.match('\A//# sound list to be processed start', line):
ignore_input = True
else:
if re.match('\A//# sound list to be processed end', line):
ignore_input = False
for item in code_array_list:
writef.write(item)
writef.write(line) # write text to file
# Notice comma to avoid automatic newline added by Python
readf.close() # close the file
writef.close();