Skip to content

Instantly share code, notes, and snippets.

@stevedoyle
Created December 11, 2012 14:33
Show Gist options
  • Save stevedoyle/4258978 to your computer and use it in GitHub Desktop.
Save stevedoyle/4258978 to your computer and use it in GitHub Desktop.
Copy files from a file list
#!/usr/bin/python -d
import argparse
from subprocess import call
def copyfile(src, dst):
call(["cp", src, dst])
parser = argparse.ArgumentParser(description='Copy files from a list to a destination directory')
parser.add_argument('filelist', help="File containing list of filenames to copy")
parser.add_argument("destdir", help="Destination directory")
args = parser.parse_args()
files = open(args.filelist, "r").xreadlines()
for f in files:
name = f.rstrip().strip()
copyfile(name, args.destdir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment