Skip to content

Commit

Permalink
Shared - Reduce String Operations
Browse files Browse the repository at this point in the history
  • Loading branch information
nlogozzo committed Nov 7, 2023
1 parent fbcd9a3 commit 325b0f4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions NickvisionTagger.Shared/Models/MusicFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,13 @@ public bool SaveTagToDisk(bool preserveModificationTimestamp)
Directory.CreateDirectory(System.IO.Path.GetDirectoryName(newPath)!);
if(File.Exists(newPath))
{
newPath = newPath.Remove(newPath.IndexOf(_dotExtension)) + $" (1){_dotExtension}";
}
var i = 2;
while (File.Exists(newPath))
{
newPath = newPath.Remove(newPath.IndexOf($" ({i - 1})")) + $" ({i}){_dotExtension}";
i++;
newPath = newPath.Remove(newPath.IndexOf(_dotExtension));
var i = 1;
while(File.Exists($"{newPath} ({i}){_dotExtension}"))
{
i++;
}
newPath += $" ({i}){_dotExtension}";
}
File.Move(Path, newPath);
Path = newPath;
Expand Down

0 comments on commit 325b0f4

Please sign in to comment.