--- a/minidlna.c
+++ b/minidlna.c
@@ -496,12 +496,13 @@
 	const char * optionsfile = "/etc/minidlna.conf";
 	char mac_str[13];
 	char *string, *word;
-	enum media_types type;
 	char *path;
 	char buf[PATH_MAX];
 	char ip_addr[INET_ADDRSTRLEN + 3] = {'\0'};
 	char log_str[75] = "general,artwork,database,inotify,scanner,metadata,http,ssdp,tivo=warn";
 	char *log_level = NULL;
+	struct media_dir_s *media_dir;
+	media_types types;
 	uid_t uid = -1;
 
 	/* first check if "-f" option is used */
@@ -598,30 +599,39 @@
 				strncpyt(friendly_name, ary_options[i].value, FRIENDLYNAME_MAX_LEN);
 				break;
 			case UPNPMEDIADIR:
-				type = ALL_MEDIA;
+				types = ALL_MEDIA;
 				path = ary_options[i].value;
-				if( *path && (path[1] == ',') && (access(path, F_OK) != 0) )
-				{
-					switch( *path )
+				word = strchr(path, ',');
+				if( word && (access(path, F_OK) != 0) )
+				{
+					types = 0;
+					while( *path )
 					{
-					case 'A':
-					case 'a':
-						type = AUDIO_ONLY;
-						break;
-					case 'V':
-					case 'v':
-						type = VIDEO_ONLY;
-						break;
-					case 'P':
-					case 'p':
-						type = IMAGES_ONLY;
-						break;
-					default:
-						DPRINTF(E_FATAL, L_GENERAL, "Media directory entry not understood [%s]\n",
-							ary_options[i].value);
-						break;
+						if( *path == 'A' || *path == 'a' )
+						{
+							types |= TYPE_AUDIO;
+						}
+						else if( *path == 'V' || *path == 'v' )
+						{
+							types |= TYPE_VIDEO;
+						}
+						else if( *path == 'P' || *path == 'p' )
+						{
+							types |= TYPE_IMAGES;
+						}
+						else if( *path == ',' )
+						{
+							path++;
+							break;
+						}
+						else
+						{
+							DPRINTF(E_FATAL, L_GENERAL, "Media directory entry not understood [%s]\n",
+								ary_options[i].value);
+							break;
+						}
+						path++;
 					}
-					path += 2;
 				}
 				path = realpath(path, buf);
 				if( !path || access(path, F_OK) != 0 )
@@ -630,19 +640,19 @@
 						ary_options[i].value, strerror(errno));
 					break;
 				}
-				struct media_dir_s * this_dir = calloc(1, sizeof(struct media_dir_s));
-				this_dir->path = strdup(path);
-				this_dir->type = type;
+				media_dir = calloc(1, sizeof(struct media_dir_s));
+				media_dir->path = strdup(path);
+				media_dir->types = types;
 				if( !media_dirs )
 				{
-					media_dirs = this_dir;
+					media_dirs = media_dir;
 				}
 				else
 				{
 					struct media_dir_s * all_dirs = media_dirs;
 					while( all_dirs->next )
 						all_dirs = all_dirs->next;
-					all_dirs->next = this_dir;
+					all_dirs->next = media_dir;
 				}
 				break;
 			case UPNPALBUMART_NAMES: