批量提取文件夹和文件名字

批量提取文件夹名称

到目录  E:\pingan\50种情绪\video  执行cmd  

dir video /b>E:\1.txt  #将该目录下video中的所有目录存到E盘的1.txt文件中

E:\pingan\50种情绪\video>dir video /b>E:\1.txt

Python读取txt文件中的名称并且批量生成文件夹

# coding=utf-8

import os

import numpy as np

baseDir ="E:\\pingan\\50种情绪\\video"

audioDir ="E:\mmmm"

os.chdir(audioDir)

file =open('E:\\1.txt')

lines = file.readlines()

aa= []

print lines

for line in lines:

cmd ="md "+line  #批量生成文件夹

os.system(cmd)

aa.append(line)

print aa

批量提取文件名称

dir *.* /b >face.txt 


得到了所有的文件夹名字

.DS_Store

Acceptance

Admiration

Aggressiveness

Angry

Annoyance

Anticipation

Apprehension

Awe

Boastfulness

Boredom

Bravery

Calm

Conflict

Contempt

Cowardice

Deceptiveness

Defiance

Depression

Desire

Disapproval

Disgust

Distraction

Embarrassed

Envy

error_log.txt

Fatigue

Fear

Gratitude

Grievance

Harmony

Hate

Insincerity

Insult

Interest

Joy

Love

Neglect

Optimism

Passiveness

Pensiveness

Pessimism

Pride

Puzzlement

Remorse

Sadness

Serenity

Shame

Sincerity

Submission

Surprise

Suspicion

Tension

Trust

Uneasiness

vitality

推荐阅读更多精彩内容