            escaped_where_name ? escaped_where_name : rx.where,
            rx.selected_files, ua->catalog->name());
     } else {
-@@ -216,6 +243,10 @@
+@@ -216,6 +256,10 @@
     if (escaped_where_name != NULL) {
        bfree(escaped_where_name);
     }
 +   
-+   if (where_use_regexp) {
++   if (have_to_free_where) {
 +      free_pool_memory(rx.where);
 +   }
  
     if (find_arg(ua, NT_("yes")) > 0) {
        pm_strcat(ua->cmd, " yes");    /* pass it on to the run command */
-@@ -235,6 +266,10 @@
+@@ -235,6 +279,10 @@
        bfree(escaped_where_name);
     }
  
-+   if (where_use_regexp) {
++   if (have_to_free_where) {
 +      free_pool_memory(rx.where);
 +   }
 +
     free_rx(&rx);
     return 0;
+ 
+@@ -331,23 +379,28 @@
+ 
+    const char *kw[] = {
+        /* These keywords are handled in a for loop */
+-      "jobid",     /* 0 */
+-      "current",   /* 1 */
+-      "before",    /* 2 */
+-      "file",      /* 3 */
+-      "directory", /* 4 */
+-      "select",    /* 5 */
+-      "pool",      /* 6 */
+-      "all",       /* 7 */
++      "jobid",       /* 0 */
++      "current",     /* 1 */
++      "before",      /* 2 */
++      "file",        /* 3 */
++      "directory",   /* 4 */
++      "select",      /* 5 */
++      "pool",        /* 6 */
++      "all",         /* 7 */
+ 
+       /* The keyword below are handled by individual arg lookups */
+-      "client",    /* 8 */
+-      "storage",   /* 9 */
+-      "fileset",   /* 10 */
+-      "where",     /* 11 */
+-      "yes",       /* 12 */
+-      "bootstrap", /* 13 */
+-      "done",      /* 14 */
++      "client",       /* 8 */
++      "storage",      /* 9 */
++      "fileset",      /* 10 */
++      "where",        /* 11 */
++      "yes",          /* 12 */
++      "bootstrap",    /* 13 */
++      "done",         /* 14 */
++      "strip_prefix", /* 15 */
++      "add_prefix",   /* 16 */
++      "add_suffix",   /* 17 */
++      "where_use_regexp",/* 18 */
++      "rwhere",       /* 19 like where + where_use_regexp */
+       NULL
+    };
  
 Index: src/dird/restore.c
 ===================================================================

+      add_suffix = ua->argv[i];
+   }
+
+   if (strip_prefix || add_suffix || add_prefix) {
+      where_use_regexp = true;
+      rx.where = bregexp_build_where(strip_prefix, add_prefix, add_suffix);
+   }
+

 /* Imported functions */
 extern void print_bsr(UAContext *ua, RBSR *bsr);
 
@@ -83,6 +83,10 @@
    JCR *jcr = ua->jcr;
    char *escaped_bsr_name = NULL;
    char *escaped_where_name = NULL;
+   bool where_use_regexp = false;
+   bool have_to_free_where = false;
+   char *strip_prefix, *add_prefix, *add_suffix;
+   strip_prefix = add_prefix = add_suffix = NULL;
 
    memset(&rx, 0, sizeof(rx));
    rx.path = get_pool_memory(PM_FNAME);
@@ -94,6 +98,41 @@
    i = find_arg_with_value(ua, "where");
    if (i >= 0) {
       rx.where = ua->argv[i];
