summaryrefslogtreecommitdiffstats
path: root/win/CS/Functions/Main.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2011-04-22 18:07:12 +0000
committersr55 <[email protected]>2011-04-22 18:07:12 +0000
commit47221be3bbe8d7dae0a714d736ae0f0b23ee08ba (patch)
tree04a0f42bf3fb8bef0e87290bf244a0eb424de23d /win/CS/Functions/Main.cs
parent63a726b5e80d17083b0f8bf3e96c5749df45bc98 (diff)
WinGui:
- Added new substitute option to the AutoName default path feature. "{source_folder_name}" git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3951 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/Functions/Main.cs')
-rw-r--r--win/CS/Functions/Main.cs30
1 files changed, 25 insertions, 5 deletions
diff --git a/win/CS/Functions/Main.cs b/win/CS/Functions/Main.cs
index ae13e3f18..41d004007 100644
--- a/win/CS/Functions/Main.cs
+++ b/win/CS/Functions/Main.cs
@@ -175,12 +175,13 @@ namespace Handbrake.Functions
if (mainWindow.drp_dvdtitle.Text != "Automatic")
{
// Get the Source Name and remove any invalid characters
-
string sourceName = Path.GetInvalidFileNameChars().Aggregate(Path.GetFileNameWithoutExtension(mainWindow.SourceName), (current, character) => current.Replace(character.ToString(), string.Empty));
+ // Remove Underscores
if (Properties.Settings.Default.AutoNameRemoveUnderscore)
sourceName = sourceName.Replace("_", " ");
+ // Switch to "Title Case"
if (Properties.Settings.Default.AutoNameTitleCase)
sourceName = sourceName.ToTitleCase();
@@ -195,7 +196,9 @@ namespace Handbrake.Functions
if (chapterFinish != chapterStart && chapterFinish != string.Empty)
combinedChapterTag = chapterStart + "-" + chapterFinish;
- // Get the destination filename.
+ /*
+ * File Name
+ */
string destinationFilename;
if (Properties.Settings.Default.autoNameFormat != string.Empty)
{
@@ -207,7 +210,9 @@ namespace Handbrake.Functions
else
destinationFilename = sourceName + "_T" + dvdTitle + "_C" + combinedChapterTag;
- // Add the appropriate file extension
+ /*
+ * File Extension
+ */
if (mainWindow.drop_format.SelectedIndex == 0)
{
switch (Properties.Settings.Default.useM4v)
@@ -229,7 +234,10 @@ namespace Handbrake.Functions
else if (mainWindow.drop_format.SelectedIndex == 1)
destinationFilename += ".mkv";
- // Now work out the path where the file will be stored.
+ /*
+ * File Destination Path
+ */
+
// If there is an auto name path, use it...
if (Properties.Settings.Default.autoNamePath.Trim() == "{source_path}" && !string.IsNullOrEmpty(mainWindow.sourcePath))
{
@@ -240,9 +248,21 @@ namespace Handbrake.Functions
autoNamePath = Path.Combine(Path.GetDirectoryName(mainWindow.sourcePath), "output_" + destinationFilename);
}
}
- // Second case: If the destination box doesn't already contain a path, make one.
+ else if (Properties.Settings.Default.autoNamePath.Contains("{source_folder_name}") && !string.IsNullOrEmpty(mainWindow.sourcePath))
+ {
+ // Second Case: We have a Path, with "{source_folder}" in it, therefore we need to replace it with the folder name from the source.
+ string path = Path.GetDirectoryName(mainWindow.sourcePath);
+ if (!string.IsNullOrEmpty(path))
+ {
+ string[] filesArray = path.Split(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
+ string sourceFolder = filesArray[filesArray.Length - 1];
+
+ autoNamePath = Path.Combine(Properties.Settings.Default.autoNamePath.Replace("{source_folder_name}", sourceFolder), destinationFilename);
+ }
+ }
else if (!mainWindow.text_destination.Text.Contains(Path.DirectorySeparatorChar.ToString()))
{
+ // Third case: If the destination box doesn't already contain a path, make one.
if (Properties.Settings.Default.autoNamePath.Trim() != string.Empty && Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location")
{
autoNamePath = Path.Combine(Properties.Settings.Default.autoNamePath, destinationFilename);