diff --git a/modules/base/src/boost_filesystem_helper.hh b/modules/base/src/boost_filesystem_helper.hh
index 5418253fd7553f7f715e8259d1f6f08615080ca1..450ffa94deaef5b230c11cd0129e3a5422549fda 100644
--- a/modules/base/src/boost_filesystem_helper.hh
+++ b/modules/base/src/boost_filesystem_helper.hh
@@ -37,6 +37,16 @@ String BFPathToString(const boost::filesystem::path& path)
 #endif
 }
 
+inline String BFPathStem(const boost::filesystem::path& path) {
+#if BOOST_FILESYSTEM_VERSION<103400
+  String name = BFPathToString(path);
+  size_t n = name.rfind('.');
+  return name.substr(0, n);
+#else
+  return path.stem();
+#endif
+}
+
 }
 
 
diff --git a/tools/molck/main.cc b/tools/molck/main.cc
index dab69250c67ce2022bc66555b0179c8386ef577e..6b896ac68313eb65e8ed10c75040f6bdd2bfa3c2 100644
--- a/tools/molck/main.cc
+++ b/tools/molck/main.cc
@@ -370,7 +370,7 @@ int main(int argc, char *argv[])
     }
     if (write_to_file) {
       fs::path input_file_path(files[i]);
-      fs::path input_filename = input_file_path.stem();
+      fs::path input_filename = BFPathStem(input_file_path);
  
 
       String input_filename_string=BFPathToString(input_filename);