diff --git a/docs/html/config_dvr.html b/docs/html/config_dvr.html
index 82920b24..a0efaa2f 100644
--- a/docs/html/config_dvr.html
+++ b/docs/html/config_dvr.html
@@ -186,7 +186,9 @@
If checked, whitespace characters (spaces and tabs) will be replaced with '-'.
Use Windows-compatible filenames
- If checked, special characters not supported by Windows like: / : \ < > | * ? ' " will be replaced with '_'.
+ If checked:
+ * special characters not supported by Windows like: / : \ < > | * ? ' " will be replaced with '_'
+ * trailing spaces ' ' and dots '.' will be removed
Changes to any of these settings must be confirmed by pressing the 'Save configuration' button before taking effect.
diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c
index f669abee..e7c8a73e 100644
--- a/src/dvr/dvr_rec.c
+++ b/src/dvr/dvr_rec.c
@@ -151,7 +151,8 @@ cleanup_filename(char *s, dvr_config_t *cfg)
if (s[0] == '.')
s[0] = '_';
- for (i = 0, len = strlen(s); i < len; i++) {
+ int len2 = strlen(s);
+ for (i = 0; i < len2; i++) {
if(s[i] == '/')
s[i] = '-';
@@ -169,6 +170,18 @@ cleanup_filename(char *s, dvr_config_t *cfg)
s[i] = '_';
}
+ if(cfg->dvr_windows_compatible_filenames) {
+ //trim trailing spaces and dots
+ for (i = len2 - 1; i >= 0; i--) {
+ if((s[i] == ' ') || (s[i] == '.')) {
+ s[i] = '\0';
+ }
+ else {
+ break;
+ }
+ }
+ }
+
return s;
}