Skip to content

Commit

Permalink
Update MusicFile.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
nlogozzo committed Nov 5, 2023
1 parent 155ef30 commit 6f26c05
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions NickvisionTagger.Shared/Models/MusicFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,15 @@ public bool SaveTagToDisk(bool preserveModificationTimestamp)
{
var newPath = $"{System.IO.Path.GetDirectoryName(Path)}{System.IO.Path.DirectorySeparatorChar}{Filename}";
Directory.CreateDirectory(System.IO.Path.GetDirectoryName(newPath)!);
var i = 1;
if(File.Exists(newPath))
{
newPath = newPath.Remove(newPath.IndexOf(_dotExtension)) + $" (1){_dotExtension}";
}
var i = 2;
while (File.Exists(newPath))
{
var oldNumber = $" ({i - 1})";
newPath = newPath.Remove(newPath.IndexOf(oldNumber), oldNumber.Length) + $" ({i})";
newPath = newPath.Remove(newPath.IndexOf($" ({i - 1})")) + $" ({i}){_dotExtension}";
i++;
}
File.Move(Path, newPath);
Path = newPath;
Expand Down

0 comments on commit 6f26c05

Please sign in to comment.