Skip to content

Commit

Permalink
빈 폴더 제거하는 옵션 동작 안 하는 문제 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
daramkun committed Jul 5, 2024
1 parent 7e341a9 commit 6660984
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions DaramRenamer.Windows/ApplyWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ private async void OnShown(EventArgs e)
ProceedTextBlock.Text = "0";
TotalTextBlock.Text = FileInfo.Files.Count.ToString();

var oldPaths = FileInfo.Files.Select(fileInfo => fileInfo.ChangedPath).ToArray();

await Task.Run(() =>
{
FileInfo.Apply(Preferences.Instance.AutomaticFixingFilename, Preferences.Instance.RenameMode,
Expand All @@ -69,23 +71,29 @@ await Dispatcher.BeginInvoke((Action) (() =>
if (errorCode != ErrorCode.NoError)
failed = true;
else
{
if (Preferences.Instance.RemoveEmptyDirectory &&
GetTotalFileCount(fileInfo.OriginalPath) == 0)
{
try
{
Directory.Delete(fileInfo.OriginalPath, recursive: true);
}
catch
{
// Ignore
}
}
}
});
});

if (Preferences.Instance.RemoveEmptyDirectory)
{
await Task.Run(() =>
{
foreach (var oldPath in oldPaths)
{
if (GetTotalFileCount(oldPath) != 0)
continue;
try
{
Directory.Delete(oldPath, recursive: true);
}
catch
{
// Ignore
}
}
});
}

switch (failed)
{
Expand Down

0 comments on commit 6660984

Please sign in to comment.