string AutoNamePath = string.Empty;\r
if (drp_dvdtitle.Text != "Automatic")\r
{\r
- // Get the Source Name - THIS NEEDS FIXED\r
- string[] sourceName = source.Split('\\');\r
- source = sourceName[sourceName.Length - 1].Replace(".iso", "").Replace(".mpg", "").Replace(".ts", "").Replace(".ps", "");\r
- source.Replace(".wmv", "").Replace(".mp4", "").Replace(".m4v", "").Replace(".avi", "").Replace(".ogm", "").Replace(".tivo", "").Replace(".img", "");\r
- source.Replace(".mov", "").Replace(".rm", "");\r
+ // Get the Source Name \r
+ string sourceName = Path.GetFileNameWithoutExtension(source);\r
\r
// Get the Selected Title Number\r
string[] titlesplit = drp_dvdtitle.Text.Split(' ');\r
if (Properties.Settings.Default.autoNameFormat != "")\r
{\r
destination_filename = Properties.Settings.Default.autoNameFormat;\r
- destination_filename = destination_filename.Replace("{source}", source).Replace("{title}", dvdTitle).Replace("{chapters}", combinedChapterTag);\r
+ destination_filename = destination_filename.Replace("{source}", sourceName).Replace("{title}", dvdTitle).Replace("{chapters}", combinedChapterTag);\r
}\r
else\r
- destination_filename = source + "_T" + dvdTitle + "_C" + combinedChapterTag;\r
+ destination_filename = sourceName + "_T" + dvdTitle + "_C" + combinedChapterTag;\r
+\r
+ // Add the appropriate file extension\r
+ if (format == 0)\r
+ destination_filename += ".mp4";\r
+ else if (format == 1)\r
+ destination_filename += ".m4v";\r
+ else if (format == 2)\r
+ destination_filename += ".mkv";\r
+ else if (format == 3)\r
+ destination_filename += ".avi";\r
+ else if (format == 4)\r
+ destination_filename += ".ogm";\r
\r
// Now work out the path where the file will be stored.\r
// First case: If the destination box doesn't already contain a path, make one.\r
- if (!dest.Contains("\\"))\r
+ if (!dest.Contains(Path.DirectorySeparatorChar.ToString()))\r
{\r
- string filePath = "";\r
- if (Properties.Settings.Default.autoNamePath.Trim() != "")\r
+ // If there is an auto name path, use it...\r
+ if (Properties.Settings.Default.autoNamePath.Trim() != "" && \r
+ Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location") \r
{\r
- if (Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location")\r
- filePath = Properties.Settings.Default.autoNamePath + "\\";\r
+ AutoNamePath = Path.Combine(Properties.Settings.Default.autoNamePath, destination_filename);\r
+ }\r
+ else // ...otherwise, output to the source directory\r
+ {\r
+ AutoNamePath = null;\r
}\r
-\r
- if (format == 0)\r
- AutoNamePath = filePath + destination_filename + ".mp4";\r
- else if (format == 1)\r
- AutoNamePath = filePath + destination_filename + ".m4v";\r
- else if (format == 2)\r
- AutoNamePath = filePath + destination_filename + ".mkv";\r
- else if (format == 3)\r
- AutoNamePath = filePath + destination_filename + ".avi";\r
- else if (format == 4)\r
- AutoNamePath = filePath + destination_filename + ".ogm";\r
}\r
else // Otherwise, use the path that is already there.\r
{\r
- string destination = AutoNamePath;\r
- string[] destName = dest.Split('\\');\r
- string[] extension = dest.Split('.');\r
- string ext = extension[extension.Length - 1];\r
-\r
- destName[destName.Length - 1] = destination_filename + "." + ext;\r
-\r
- string fullDest = "";\r
- foreach (string part in destName)\r
- {\r
- if (fullDest != "")\r
- fullDest = fullDest + "\\" + part;\r
- else\r
- fullDest = fullDest + part;\r
- }\r
- return fullDest;\r
+ // Use the path and change the file extension to match the previous destination\r
+ AutoNamePath = Path.Combine(Path.GetDirectoryName(dest), destination_filename);\r
+ AutoNamePath = Path.ChangeExtension(AutoNamePath, Path.GetExtension(dest));\r
}\r
}\r
\r
}\r
\r
}\r
-}
\ No newline at end of file
+}\r
{\r
queueWindow.setQueue();\r
queueWindow.Show();\r
+ queueWindow.Activate();\r
}\r
private void tb_preview_Click(object sender, EventArgs e)\r
{\r
\r
// Run the autoName & chapterNaming functions\r
if (Properties.Settings.Default.autoNaming == "Checked")\r
- text_destination.Text = hb_common_func.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, text_source.Text, text_destination.Text, drop_format.SelectedIndex);\r
+ {\r
+ string autoPath = hb_common_func.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, text_source.Text, text_destination.Text, drop_format.SelectedIndex);\r
+ if (autoPath != null)\r
+ text_destination.Text = autoPath;\r
+ else\r
+ MessageBox.Show("You currently have automatic file naming enabled for the destination box, but you do not have a default direcotry set. You should set this in the program options (see Tools Menu)","Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ }\r
\r
data_chpt.Rows.Clear();\r
DataGridView chapterGridView = hb_common_func.chapterNaming(data_chpt, drop_chapterFinish.Text);\r