在Pyhon中按名称整理文件夹

时间:2019-02-19 17:13:01

标签: python file loops

我大约有成千上万个具有类似名称的文件夹:

AE_01
AE_02
.
.
AE_1010

ER_01
ER_02
.
.
ER_266

PP_01 
.
.
PP_0111

我想将这些文件分别组织为AE ER PP并放在这些文件夹中,我想像这样存储:

Main_Folder
 |-AE
   |-AE_01 
   |-AE_02 .. and others

 |-ER
   |-ER_01 
   |-ER_02 .. and others

1 个答案:

答案 0 :(得分:1)

Python正则表达式(用于字符串匹配)

Python regex

Python路径操纵

Python os.path

Python glob

还有一点for循环应该可以完成您的工作。