filepath = next(os.walk(rootpath))[0] dirlist = next(os.walk(rootpath))[1] filelist = next(os.walk(rootpath))[2]