Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Script para obtener imgenes aleatorias de un directorio.
- # Fede Diaz (aka nordri) fede3birras(at)gmail.com
- #!/usr/bin/env python
- import random, os
- # Esta funcin genera un vector con las imgenes del directorio
- def total(path):
- try:
- i = 0
- for a in os.listdir(path):
- i += 1
- return i
- except OSError, e:
- print "Error del sistema de archivos:", e
- path = "PATH donde se encuentran las imgenes"
- t = total(path)
- numero = random.randint(1,t)
- i = 0
- # Elegimos una imagen y la abrimos con gqview
- for fichero in os.listdir(path):
- fname = os.path.join(path, fichero)
- i += 1
- if i == numero:
- print "Elegido %s de %s" %(i,t)
- os.system('gqview ' + fname)
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement