Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import os
- import shutil
- out = subprocess.Popen('ls', shell=True, stdout=subprocess.PIPE)
- lineas_c = out.stdout.readlines()
- for a in lineas_c:
- if os.path.isfile(a.strip()):
- print 'Esto es un archivo %s' % a.strip()
- print '\tEsta en la carpeta %s' % os.path.dirname(os.path.abspath(a.strip()))
- if os.path.isdir(a.strip()):
- print 'Esto es un directorio %s' % a.strip()
- #copiando todosw los archivos de a a /tmp, (en un nivel)
- absp = os.path.abspath(a.strip())
- for d in os.listdir(absp):
- if os.path.isfile(d.strip()):
- shutil.copy2(absp, '/tmp/%s' % a.strip())
Advertisement
Add Comment
Please, Sign In to add comment