Question: I am extremely desperate and tired.
My problem is the following:
I have created a REST-Service for a project I am working on for school. There I have a few requests which interact with my db based upon a Path Variable. The catch is, that I cannot request something over the value of 9. To further illustrate, what I mean, I have copied the following snippet:

```
@GET
@Path("/Child/{Child: \\d+}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response Child(@PathParam ("Child")int child) throws IOException{
    DAO dao = new DAO();
    List<Child> Child;
    try{
        Child = dao.Child(child);
        ResponseBuilder rb = Response.ok();
        rb.entity(new GenericEntity<List<Child>>(Child) {});

        return rb.build();

    }catch(Exception e){
        ResponseBuilder rp = Response.status(404);
        return rp.build();
    }

}

```

Instead of returning the Child object with the matching index (which exists, I have checked multiple times to see, if I am really not just overlooking the obvious), it returns a 404 code. It doesn't even seem to catch the exception because I have changed the response code and it still returned the same result. I have also tried to customize the variable (as seen above with \d+, there have been various other expressions, but none of them worked either). I have searched the web for answers, but none of the answers found were able to help me. If more information is needed, I am more than happy to provide it.

Answer: 
You can do so using `glob` to search all files with a certain name. Here's an example:

```
import shutil
import glob, sys, os

src_files = glob.glob1(sys.argv[3], '*%s*'%sys.argv[1])
dest = sys.argv[5]
for name in src_files:
    shutil.copy(os.path.join(sys.argv[3], name), os.path.join(dest, name))

```

`py modulename.py module --src "C:/orig/path/to/some" --dest "C:/copy/path/to/some"`

To improve this code, you can use argparse instead of sys.argv.

Here's a more professional way:

```
import shutil, argparse
import glob, os

parser = argparse.ArgumentParser()
parser.add_argument('name', metavar='N', type=str, nargs='+')
parser.add_argument('--src', required=False)
parser.add_argument('--dest',  required=False)
parsed = parser.parse_args()

src_files = glob.glob1(parsed.src, '*%s*'%parsed.name[0])
dest = parsed.dest
for name in src_files:
    shutil.copy(os.path.join(parsed.src, name), os.path.join(dest, name))

```

Like all other command calling, you will need to use the `=` when calling: 
`py modulename.py module --src="C:/orig/path/to/some" --dest="C:/copy/path/to/some"`
Based on the comments and answers, i have rewritten the script to following:

```
import argparse, shutil, glob, sys, ntpath, os

def parse_args():
    # Set up the parser, and tell it what arguments to expect
    parser = argparse.ArgumentParser()
    parser.add_argument('--search')
    parser.add_argument('--src')
    parser.add_argument('--dest')
    # Get the list of arguments from the command line, starting from
    # index 1 (since index 0 is the name of this file).
    raw_args = sys.argv[1:]
    # Parse the args, and return the object containing them
    args = parser.parse_args(raw_args)
    return args

args = parse_args()

for filename in glob.iglob(args.src+'/**/*'+args.search+'*', recursive=True):
    src_file = os.path.join(args.src, filename)
    dest_file = filename.replace(args.src,args.dest)
    dest_dir = os.path.dirname(dest_file)
    if os.path.isdir(src_file):
        continue
    if not os.path.exists(dest_dir):
        os.makedirs(dest_dir)
    if (os.path.isfile(src_file)):
        shutil.copy(src_file, dest_file)

```

Now i can do this:

```
py copy_files.py --search "searchterm" --src "C:/orig/path/to/some" --dest "C:/copy/path/to/some"

```

After the edit of [abccd](https://stackoverflow.com/users/6622817/abccd) i suppose i can still improve these lines:

```
for filename in glob.iglob(args.src+'/**/*'+args.search+'*', recursive=True):
    src_file = os.path.join(args.src, filename)
    dest_file = filename.replace(args.src,args.dest)
    dest_dir = os.path.dirname(dest_file)

```