import os
  import shutil
  #pach 这里引号中输入待处理文件夹的路径
  path = 'C:\USER\'
  files = os.listdir(path)
  for f in files:
      f = path + '/'+f
      if os.path.isfile(f) :
          folder_name = path + f.split('.')[-1]
          print('move{} to {}'.format(f,folder_name))
          if not os.path.exists(folder_name) :
              os.makedirs(folder_name)
              shutil.move(f,folder_name)
      else:
          shutil.move(f,folder_name)
最后修改:2020 年 10 月 11 日
如果觉得我的文章对你有用,请随意赞赏