Index: trunk/psModules/src/camera/pmFPAfile.c
===================================================================
--- trunk/psModules/src/camera/pmFPAfile.c	(revision 7618)
+++ trunk/psModules/src/camera/pmFPAfile.c	(revision 7679)
@@ -114,29 +114,4 @@
 }
 
-// XXX reconsider this function name / concept
-# if 0
-bool pmFPAfileAddFileNames (psMetadata *files, char *name, char *value, int mode)
-{
-    PS_ASSERT_PTR_NON_NULL(files, false);
-    PS_ASSERT_PTR_NON_NULL(name, false);
-    PS_ASSERT_INT_POSITIVE(strlen(name), false);
-    PS_ASSERT_PTR_NON_NULL(value, false);
-    PS_ASSERT_INT_POSITIVE(strlen(value), false);
-
-    // add the output names to the output-type files
-    psMetadataItem *item = NULL;
-    psMetadataIterator *iter = psMetadataIteratorAlloc (files, PS_LIST_HEAD, NULL);
-    while ((item = psMetadataGetAndIncrement (iter)) != NULL) {
-        pmFPAfile *file = item->data.V;
-
-        if (file->mode == mode) {
-            psMetadataAddStr (file->names, PS_LIST_TAIL, name, PS_META_NO_REPLACE, "", value);
-        }
-    }
-    psFree (iter);
-    return true;
-}
-# endif
-
 // select the rule from the camera configuration, perform substitutions as needed
 char *pmFPAfileNameFromRule (char *rule, pmFPAfile *file, const pmFPAview *view)
@@ -166,4 +141,14 @@
         }
     }
+    if (strstr (newName, "{CHIP.N}") != NULL) {
+        char *name = NULL;
+        if (view->chip < 0) {
+            psStringAppend (&name, "XX");
+        } else {
+            psStringAppend (&name, "%02d", view->chip);
+        }
+        newName = psStringSubstitute (newName, name, "{CHIP.N}");
+        psFree (name);
+    }
     if (strstr (newName, "{CELL.NAME}") != NULL) {
         pmCell *cell = pmFPAviewThisCell (view, file->fpa);
@@ -175,4 +160,13 @@
         }
     }
+    if (strstr (newName, "{CELL.N}") != NULL) {
+        char *name = NULL;
+        if (view->cell < 0) {
+            psStringAppend (&name, "XX");
+        } else {
+            psStringAppend (&name, "%02d", view->cell);
+        }
+        newName = psStringSubstitute (newName, name, "{CELL.N}");
+    }
     if (strstr (newName, "{EXTNAME}") != NULL) {
         pmHDU *hdu = pmFPAviewThisHDU (view, file->fpa);
@@ -181,4 +175,30 @@
         }
     }
+    if (strstr (newName, "{FILTER}") != NULL) {
+        if (file->fpa != NULL) {
+            char *name = psMetadataLookupStr (NULL, file->fpa->concepts, "FPA.FILTER");
+            if (name != NULL) {
+                newName = psStringSubstitute (newName, name, "{FILTER}");
+            }
+        }
+    }
+    if (strstr (newName, "{CAMERA}") != NULL) {
+        if (file->fpa != NULL) {
+            char *name = psMetadataLookupStr (NULL, file->fpa->concepts, "FPA.CAMERA");
+            if (name != NULL) {
+                newName = psStringSubstitute (newName, name, "{CAMERA}");
+            }
+        }
+    }
+    if (strstr (newName, "{FILTER.ID}") != NULL) {
+        if (file->fpa != NULL) {
+            char *filterName = psMetadataLookupStr (NULL, file->fpa->concepts, "FPA.FILTER");
+            psMetadata *filterTable = psMetadataLookupPtr (NULL, file->camera, "FILTER.ID");
+            if (filterName && filterTable) {
+                char *ID = psMetadataLookupStr (NULL, filterTable, filterName);
+                newName = psStringSubstitute (newName, ID, "{FILTER.ID}");
+            }
+        }
+    }
     return newName;
 }
