Name: Anonymous 2010-01-18 23:35
need a bash script or python to copy files in batches of 500 and put them into subdirectories
there can be any number of files (I have 15k), and the filenames are irrelevant, and the names of the subdirectories that are created to house the files is irrelevant
here's what I was trying to get work in python but it
errors out at file 339, don't know why
there can be any number of files (I have 15k), and the filenames are irrelevant, and the names of the subdirectories that are created to house the files is irrelevant
here's what I was trying to get work in python but it
errors out at file 339, don't know why
def BreakUp(indir):
biglist = glob.glob('*.mp3')
dircount = 0
filecount = 0
while biglist:
dircount += 1
os.mkdir('subdir'+str(dircount))
for i in range(500):
filecount += 1
try:
src = biglist[filecount].translate("(copy)")
os.system ("mv"+ " " + src + " subdir"+ str(dircount))
biglist.remove(src)
except IndexError:
raise IndexError, "could not return item " + str(filecount) + " from list " + str(biglist)
continue
if __name__ == '__main__':
BreakUp(".")