I am trying to group files into folders based on the prefix of the filename. Error: os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not tuple
I am getting the error on the line that corresponds to dir_path = file[:-8]
import os
import pickle
from os.path import join, exists
import shutil
RootDir = r'D:Folder'
count = 0
for file in os.walk((os.path.normpath(RootDir)), topdown=False):
dir_path = file[:-8]
if not os.path.exists(dir_path):
os.makedirs(dir_path)
if os.path.exists(dir_path):
shutil.move(file)
Any insights as to where I did it wrong? Thank you.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…