Skip to content

Commit

Permalink
Move txt files when moving images #239
Browse files Browse the repository at this point in the history
  • Loading branch information
RupertAvery committed Apr 20, 2024
1 parent 3175e78 commit 3430150
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Diffusion.Toolkit/MainWindow.xaml.Scanning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,24 @@ private async Task MoveFiles(ICollection<ImageEntry> images, string path, bool r
{
var fileName = Path.GetFileName(image.Path);
var newPath = Path.Join(path, fileName);

var directoryName = Path.GetDirectoryName(image.Path);
var fileNameOnly = Path.GetFileNameWithoutExtension(fileName);

var txtFileName = $"{fileNameOnly}.txt";

var txtPath = Path.Join(directoryName, txtFileName);
var newTxtPath = Path.Join(path, txtFileName);

if (image.Path != newPath)
{
File.Move(image.Path, newPath);

if (File.Exists(txtPath))
{
File.Move(txtPath, newTxtPath);
}

if (remove)
{
_dataStore.DeleteImage(image.Id);
Expand Down

0 comments on commit 3430150

Please sign in to comment.