We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 72742f7 commit cf7ea73Copy full SHA for cf7ea73
varredor de pastas.py
@@ -0,0 +1,18 @@
1
+import os
2
+
3
+def listar_arquivos_pastas(diretorio, saida):
4
+ with open(saida, 'w', encoding='utf-8') as arquivo_saida:
5
+ for raiz, pastas, arquivos in os.walk(diretorio):
6
+ nivel = raiz.replace(diretorio, '').count(os.sep)
7
+ indentacao = ' ' * 4 * nivel
8
+ arquivo_saida.write(f"{indentacao}[Pasta] {os.path.basename(raiz)}\n")
9
10
+ sub_indentacao = ' ' * 4 * (nivel + 1)
11
+ for arquivo in arquivos:
12
+ arquivo_saida.write(f"{sub_indentacao}- {arquivo}\n")
13
14
+if __name__ == "__main__":
15
+ PATH_B = "/media/code/DRIVERS"
16
+ saida_arquivo = "saida.txt"
17
+ listar_arquivos_pastas(PATH_B, saida_arquivo)
18
+ print(f"Listagem concluída! Verifique o arquivo {saida_arquivo}")
0 commit comments