Index: /tags/ipp-pv3-cr-20140614/psModules/src/config/pmConfig.c
===================================================================
--- /tags/ipp-pv3-cr-20140614/psModules/src/config/pmConfig.c	(revision 36930)
+++ /tags/ipp-pv3-cr-20140614/psModules/src/config/pmConfig.c	(revision 36931)
@@ -965,4 +965,42 @@
                                   "Original replaced by -R option", newRule);
         }
+        psFree(camerasIter);
+    }
+
+    // Look for command-line options for files to replace
+    while ((argNum = psArgumentGet(*argc, argv, "-photcode-rule")) > 0) {
+        psArgumentRemove(argNum, argc, argv);
+        if (argNum >= *argc) {
+            psError(PM_ERR_CONFIG, true,
+                    "-photcode-rule provided without new rule.");
+            psFree(config);
+            return NULL;
+        }
+
+        psString newrule = psStringCopy(argv[argNum]); // The filerule, to be modified
+        psArgumentRemove(argNum, argc, argv);
+
+        psMetadata *cameras = psMetadataLookupMetadata(NULL, config->system, "CAMERAS"); // List of cameras
+        if (!cameras) {
+            psError(PM_ERR_CONFIG, false, "Unable to find CAMERAS in the site configuration.\n");
+            return false;
+        }
+
+        psMetadataIterator *camerasIter = psMetadataIteratorAlloc(cameras, PS_LIST_HEAD, NULL); // Iterator
+        psMetadataItem *cameraItem;     // Item from iteration
+        while ((cameraItem = psMetadataGetAndIncrement(camerasIter))) {
+            // Silently ignore problems --- they will be caught later, because if the user wants the nominated
+            // file and it's not available for that camera, then they will know.
+
+            if (cameraItem->type != PS_DATA_METADATA) {
+                psTrace("psModules.config", 2,
+                        "Entry %s in CAMERAS is not of type METADATA --- ignored.", cameraItem->name);
+                continue;
+            }
+            psMetadata *camera = cameraItem->data.md; // Camera configuration
+
+	    psMetadataAddStr (camera, PS_LIST_TAIL, "PHOTCODE.RULE", PS_META_REPLACE, "original replaced by -photcode-rule option", newrule);
+        }
+	psFree(newrule);
         psFree(camerasIter);
     }
