def collect(ip,arg):
    """ collect foo/a.txt rec:bar=*.py
    
    Copies foo/a.txt to ~/_ipython/collect/foo/a.txt and *.py from bar,
    likewise
    
    Without args, try to open ~/_ipython/collect dir (in win32 at least).
    """
    from IPython.external.path import path
    basedir = path(ip.ipython_dir + '/collect')
    try:    
        fs = mglob.expand(arg.split(None,1)[1])
    except __HOLE__:
        os.startfile(basedir)
        return
    for f in fs:
        f = path(f)
        trg = basedir / f.splitdrive()[1].lstrip('/\\')
        if f.isdir():
            print("mkdir",trg)
            trg.makedirs()
            continue
        dname = trg.dirname()
        if not dname.isdir():
            dname.makedirs()
        print(f,"=>",trg)
        shutil.copy2(f,trg)
dataset/ETHPy150Open ipython/ipython-py3k/IPython/quarantine/ipy_fsops.py/collect