Now for the flames...
David Broadwell
dbroadwell at mindspring.com
Sat Jun 24 07:02:01 EDT 2000
Ok, now, what else am i doing that really isn't necessary?
(ie: point out my c hangups, please.)
Ignore the exre print statements, most of those i'll comment out or
otherwise handle. i am looking for actuall programing advice..
specifically on if i have used any non-platform independent stuff.. (so
that when i later migrate to haveing this same file structure that i am
designing my toold for, they will still function.)
# code follows
import os
import sys
output = 'out.txt'
filetype = 'm3u'
directorylist = []
filelist = []
def doit():
cwd = []
print 'reading current directory'
cwd = os.listdir('.')
print 'building directorylist'
for item in cwd:
if (os.path.isdir(item)):
directorylist.append(item)
print 'building filelist'
for item in cwd:
if (item[(len(item)-3):] == filetype):
filelist.append(item)
del cwd
print 'Checking for subdirectories to check.'
for item in directorylist:
print 'subdirectory ' + item + ' found, scanning.'
os.chdir(item)
subdir = []
subdir = os.listdir('.')
for thing in subdir[:]:
print thing + ' ',
if (thing[(len(thing)-3):] == filetype):
print 'Yup.'
# join item(path) to file
# add to filelist
else:
print 'Nope.'
subdir.remove(thing)
del subdir
os.chdir('..')
def merge(filelist):
if (filelist):
outbuffer=open(output,'w')
for item in filelist:
inbuffer=open(item)
outbuffer.write(inbuffer.read())
inbuffer.close()
outbuffer.close()
else:
print 'No files to process, Exiting...'
sys.exit()
doit()
--
~We're all fallen angels who've forgotten how to fly~
Remember how: http://www.cyber-action.com/oed/dbroadwell.html
--
More information about the Python-list
mailing list