1
I have a list of directories to be created that has this structure :
Bla / Bla / Bla1.md
Bla / Bla / Bla2.md
Blu / Blue.md
Ble.md
But the archives .md
should not be created, but the folders containing the same should, and for that I made the following script :
# -*- coding: utf-8 -*-
import os
def build ( address ) :
address = '/home/bezerk/Imagens/' + address
if not os.path.exists ( address ) :
os.makedirs ( address )
with open ( 'Arquivo.txt', 'r' ) as file :
for line in file.readlines () :
if line.endswith ( '.md' ) :
# Tratamento aqui
build ( line [:-3] )
else :
build ( line )
But I don’t know why python doesn’t recognize this Bla / Bla / Bla1.md
but a separate item like this one Ble.md
he recognizes, if anyone can give me insights to solve I am grateful
What do you mean by "python doesn’t recognize"? I made a test here by making the directories with the names you suggest and worked normally.
– Sidon
When I run here on my pc it doesn’t create folders like
Bla / Bla / Bla1.md
that has more than one directory inside, but if I put in the filetxt
only folders without subfolders it creates them perfectly ( This is what I was wondering because I didn’t see anything wrong in the code, but ... ) - and when it creates, folders are created with extension.md
and becomes a mess– user48471