def collect(ip,arg):
    from IPython.external.path import path
    basedir = path(ip.ipython_dir + '/collect')
    try:    
        fs = mglob.expand(arg.split(None,1)[1])
    except IndexError:
        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)
collect foo/a.txt rec:bar=*.py
dataset/ETHPy150Open ipython/ipython-py3k/IPython/quarantine/ipy_fsops.py/collect