Ferkner / mediarenamer

Automatically exported from code.google.com/p/mediarenamer
0 stars 0 forks source link

Windows renaming is not case sensitive - FIX included #26

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Renaming a film to the same name with different casing
eg: Alone In The Dark => Alone in the Dark

Suggested solution:

public void renameMovie() {
            if (needRenaming()) {
                var fi = new FileInfo(filename);
                var modifiedFilename = fi.DirectoryName + @"\" +
modifiedName();
                var modnameLower = modifiedFilename.ToLower().Trim();
                if (modnameLower == fi.FullName.ToLower())
                {
                    if (fi.Exists)
                    {
                        File.Move(modnameLower,modnameLower + ".rename");
                        File.Move(modnameLower + ".rename", modifiedFilename);
                        return;
                    }
                }
                if (!File.Exists(modifiedFilename)) {
                    fi.MoveTo(modifiedFilename);
                }
                else {
                    MessageBox.Show("A file with the same name already
exists. \nYou cannot rename the file " + fi.Name, Application.ProductName,
MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

Original issue reported on code.google.com by me%franc...@gtempaccount.com on 24 Sep 2009 at 8:01