Skip to content

Instantly share code, notes, and snippets.

@juanpabloaj
Created July 5, 2012 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanpabloaj/3050904 to your computer and use it in GitHub Desktop.
Save juanpabloaj/3050904 to your computer and use it in GitHub Desktop.
busqueda del 10000 en varios archivos
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import shutil
import random
def verificar(path):
# verificar que el archivo tiene un 10000
archivo = open(path,'r')
for linea in archivo:
#print linea.replace('\n','')
if '10000' in linea:
return True
local = '.'
destino = '/out'
nuevo_dir = local + destino
if not os.path.exists(nuevo_dir):
os.mkdir(nuevo_dir)
for dirname, dirnames, filenames in os.walk(local):
#print dirname, filenames
if 'dir' in dirname:
for filename in filenames:
if '.txt' in filename:
fullname = os.path.join(dirname,filename)
#print fullname
if verificar(fullname):
nuevo_file = nuevo_dir+'/copia_'+filename
shutil.copyfile(fullname,nuevo_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment