Last active
August 29, 2015 14:06
-
-
Save Ismael-VC/595a39941e134e800132 to your computer and use it in GitHub Desktop.
Crea n número de carpetas del mismo nombre y numeradas usando os.mkdir y subproces.call.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
''' | |
Moraleja: Usar "os" para crear carpetas. :P | |
''' | |
from os import mkdir | |
def crear_carpeta_0(nombre_carpeta, cantidad_carpetas=1): | |
for indice in range(cantidad_carpetas): | |
formato_nombre = '{0}_{1}'.format(nombre, indice+1) | |
mkdir(formato_nombre) | |
from subprocess import call | |
def crear_carpeta_1(nombre_carpeta, cantidad_carpetas=1): | |
for indice in range(cantidad_carpetas): | |
formato_nombre = '{0}_{1}'.format(nombre, indice+1) | |
call('mkdir {0}'.format(formato_nombre), shell=True) | |
if __name__ == '__main__': | |
print ('Bienvenido a: crear_carpeta_0') | |
nombre = input('Introduce el nombre de la carpeta\n--> ') | |
cantidad = int(input('\nIntroduce el número de carpetas' | |
' que deseas crear\n--> ')) | |
crear_carpeta_0(nombre, cantidad) | |
print ('Bienvenido a: crear_carpeta_1') | |
nombre = input('Introduce el nombre de la carpeta\n--> ') | |
cantidad = int(input('\nIntroduce el número de carpetas' | |
' que deseas crear\n--> ')) | |
crear_carpeta_1(nombre, cantidad) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment