Working on the gui
This commit is contained in:
parent
52f07cf547
commit
3e40ab9eec
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -12,7 +12,12 @@ public static class FilesHelper
|
|||||||
var fileExt = Path.GetExtension(file);
|
var fileExt = Path.GetExtension(file);
|
||||||
foreach (var supportedFileExtension in SupportedFileExtensions)
|
foreach (var supportedFileExtension in SupportedFileExtensions)
|
||||||
{
|
{
|
||||||
if (fileExt.Equals(supportedFileExtension, StringComparison.InvariantCultureIgnoreCase))
|
if (
|
||||||
|
fileExt.Equals(
|
||||||
|
supportedFileExtension,
|
||||||
|
StringComparison.InvariantCultureIgnoreCase
|
||||||
|
)
|
||||||
|
)
|
||||||
yield return file;
|
yield return file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
25
PhotoRenamer/FolderExtension.cs
Normal file
25
PhotoRenamer/FolderExtension.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
namespace PhotoRenamer;
|
||||||
|
|
||||||
|
public static class FolderExtension
|
||||||
|
{
|
||||||
|
public static string CreateFolderStructureByDate(string targetRoot, DateOnly dateTime)
|
||||||
|
{
|
||||||
|
var folder = BuildTargetDirectoryByDate(targetRoot, dateTime);
|
||||||
|
if (!Directory.Exists(folder))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
return folder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string BuildTargetDirectoryByDate(string targetRoot, DateOnly dateTime)
|
||||||
|
{
|
||||||
|
return Path.Combine(targetRoot, dateTime.Year.ToString(), dateTime.Month.ToString("D2"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string[] GetAllFiles(string sourceRoot)
|
||||||
|
{
|
||||||
|
return Directory.GetFiles(sourceRoot, "*", SearchOption.AllDirectories);
|
||||||
|
}
|
||||||
|
}
|
61
PhotoRenamer/MediaFileExtension.cs
Normal file
61
PhotoRenamer/MediaFileExtension.cs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
using MetadataExtractor;
|
||||||
|
using MetadataExtractor.Formats.Exif;
|
||||||
|
using MetadataExtractor.Formats.QuickTime;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
|
namespace PhotoRenamer;
|
||||||
|
|
||||||
|
public static class MediaFileExtension
|
||||||
|
{
|
||||||
|
public static DateTime GetDateTimeFromSourceFile(string file)
|
||||||
|
{
|
||||||
|
DateTime dateTime;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var metadata = ImageMetadataReader.ReadMetadata(file);
|
||||||
|
dateTime =
|
||||||
|
GetDateTimeFromExif(metadata)
|
||||||
|
?? GetDateTimeFromMp4(metadata)
|
||||||
|
?? GetDateTimeFromLastWrite(file);
|
||||||
|
}
|
||||||
|
catch (ImageProcessingException e)
|
||||||
|
{
|
||||||
|
Log.Error(e, $"Error reading file information from {file}");
|
||||||
|
dateTime = GetDateTimeFromLastWrite(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DateTime GetDateTimeFromLastWrite(string file)
|
||||||
|
{
|
||||||
|
var creationTime = File.GetLastWriteTime(file);
|
||||||
|
return creationTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DateTime? GetDateTimeFromExif(
|
||||||
|
IEnumerable<MetadataExtractor.Directory> directories
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
directories
|
||||||
|
.OfType<ExifIfd0Directory>()
|
||||||
|
.FirstOrDefault()
|
||||||
|
?.TryGetDateTime(ExifDirectoryBase.TagDateTime, out var dateTime) == true
|
||||||
|
? dateTime
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DateTime? GetDateTimeFromMp4(
|
||||||
|
IEnumerable<MetadataExtractor.Directory> directories
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
directories
|
||||||
|
.OfType<QuickTimeMovieHeaderDirectory>()
|
||||||
|
.FirstOrDefault()
|
||||||
|
?.TryGetDateTime(QuickTimeMovieHeaderDirectory.TagCreated, out var dateTime) == true
|
||||||
|
? dateTime
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
}
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="PublishAotCompressed" Version="1.0.1" />
|
<PackageReference Include="PublishAotCompressed" Version="1.0.2" />
|
||||||
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
|
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0" />
|
||||||
|
@ -28,6 +28,10 @@ internal static class Program
|
|||||||
public static IConfigurationBuilder CreateHostBuilder(string[] args) =>
|
public static IConfigurationBuilder CreateHostBuilder(string[] args) =>
|
||||||
new ConfigurationBuilder()
|
new ConfigurationBuilder()
|
||||||
.SetBasePath(Directory.GetCurrentDirectory())
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
.AddJsonFile(AppDomain.CurrentDomain.BaseDirectory + "\\appsettings.json", optional: true, reloadOnChange: true)
|
.AddJsonFile(
|
||||||
|
AppDomain.CurrentDomain.BaseDirectory + "\\appsettings.json",
|
||||||
|
optional: true,
|
||||||
|
reloadOnChange: true
|
||||||
|
)
|
||||||
.AddCommandLine(args);
|
.AddCommandLine(args);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
using System.Runtime.InteropServices.JavaScript;
|
using Microsoft.Extensions.Configuration;
|
||||||
using MetadataExtractor;
|
|
||||||
using MetadataExtractor.Formats.Exif;
|
|
||||||
using MetadataExtractor.Formats.QuickTime;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Spectre.Console;
|
using Spectre.Console;
|
||||||
using Directory = System.IO.Directory;
|
|
||||||
|
|
||||||
namespace PhotoRenamer;
|
namespace PhotoRenamer;
|
||||||
|
|
||||||
@ -17,15 +12,21 @@ internal class Renamer
|
|||||||
|
|
||||||
public Renamer(IConfiguration configuration)
|
public Renamer(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
_sourcePath = Path.GetFullPath(configuration["Source"]);
|
_sourcePath = Path.GetFullPath(
|
||||||
_targetPath = Path.GetFullPath(configuration["Target"]);
|
configuration["Source"]
|
||||||
|
?? throw new NotSupportedException("Source directory needs to be set.")
|
||||||
|
);
|
||||||
|
_targetPath = Path.GetFullPath(
|
||||||
|
configuration["Target"]
|
||||||
|
?? throw new NotSupportedException("Target directory needs to be set.")
|
||||||
|
);
|
||||||
Log.Information($"Source path: {_sourcePath}");
|
Log.Information($"Source path: {_sourcePath}");
|
||||||
Log.Information($"Target path: {_targetPath}");
|
Log.Information($"Target path: {_targetPath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> RunAsync()
|
public async Task<int> RunAsync()
|
||||||
{
|
{
|
||||||
var files = Directory.GetFiles(_sourcePath, "*", SearchOption.AllDirectories);
|
var files = FolderExtension.GetAllFiles(_sourcePath);
|
||||||
_currentCount = 0;
|
_currentCount = 0;
|
||||||
var po = new ParallelOptions { MaxDegreeOfParallelism = 3 };
|
var po = new ParallelOptions { MaxDegreeOfParallelism = 3 };
|
||||||
await AnsiConsole
|
await AnsiConsole
|
||||||
@ -37,24 +38,22 @@ internal class Renamer
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async ValueTask Body(string file, ProgressContext progressContext, CancellationToken token)
|
private async ValueTask Body(
|
||||||
|
string file,
|
||||||
|
ProgressContext progressContext,
|
||||||
|
CancellationToken token
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
if (token.IsCancellationRequested)
|
||||||
|
return;
|
||||||
var task = progressContext.AddTask($"[green]{file}[/]");
|
var task = progressContext.AddTask($"[green]{file}[/]");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DateTime dateTime;
|
var dateTime = MediaFileExtension.GetDateTimeFromSourceFile(file);
|
||||||
try
|
var folder = FolderExtension.CreateFolderStructureByDate(
|
||||||
{
|
_targetPath,
|
||||||
var directories = ImageMetadataReader.ReadMetadata(file);
|
DateOnly.FromDateTime(dateTime)
|
||||||
dateTime = GetDateTimeFromExif(directories) ?? GetDateTimeFromMp4(directories) ?? GetDateTimeFromLastWrite(file);
|
);
|
||||||
}
|
|
||||||
catch (ImageProcessingException e)
|
|
||||||
{
|
|
||||||
Log.Error(e, $"Error reading file information from {file}");
|
|
||||||
dateTime = GetDateTimeFromLastWrite(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
var folder = CreateFolder(dateTime);
|
|
||||||
var progress = new Progress<double>(v => task.Value = v * 100);
|
var progress = new Progress<double>(v => task.Value = v * 100);
|
||||||
|
|
||||||
await CopyFileAsync(folder, file, progress);
|
await CopyFileAsync(folder, file, progress);
|
||||||
@ -70,22 +69,6 @@ internal class Renamer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DateTime GetDateTimeFromLastWrite(string file)
|
|
||||||
{
|
|
||||||
var creationTime = File.GetLastWriteTime(file);
|
|
||||||
return creationTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static DateTime? GetDateTimeFromExif(IEnumerable<MetadataExtractor.Directory> directories)
|
|
||||||
{
|
|
||||||
return directories.OfType<ExifIfd0Directory>().FirstOrDefault()?.TryGetDateTime(ExifDirectoryBase.TagDateTime, out var dateTime) == true ? dateTime : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static DateTime? GetDateTimeFromMp4(IEnumerable<MetadataExtractor.Directory> directories)
|
|
||||||
{
|
|
||||||
return directories.OfType<QuickTimeMovieHeaderDirectory>().FirstOrDefault()?.TryGetDateTime(QuickTimeMovieHeaderDirectory.TagCreated, out var dateTime) == true ? dateTime : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ResetTimes(FileSystemInfo destination, FileSystemInfo source)
|
private static void ResetTimes(FileSystemInfo destination, FileSystemInfo source)
|
||||||
{
|
{
|
||||||
destination.LastWriteTime = source.LastWriteTime;
|
destination.LastWriteTime = source.LastWriteTime;
|
||||||
@ -94,7 +77,11 @@ internal class Renamer
|
|||||||
destination.CreationTimeUtc = source.CreationTimeUtc;
|
destination.CreationTimeUtc = source.CreationTimeUtc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task CopyFileAsync(string folder, string file, IProgress<double>? progress = null)
|
private static async Task CopyFileAsync(
|
||||||
|
string folder,
|
||||||
|
string file,
|
||||||
|
IProgress<double>? progress = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
var destination = new FileInfo(Path.Combine(folder, Path.GetFileName(file)));
|
var destination = new FileInfo(Path.Combine(folder, Path.GetFileName(file)));
|
||||||
var source = new FileInfo(file);
|
var source = new FileInfo(file);
|
||||||
@ -104,22 +91,21 @@ internal class Renamer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await using var sourceStream = File.Open(source.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
await using var sourceStream = File.Open(
|
||||||
await using var targetStream = File.Open(destination.FullName, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
|
source.FullName,
|
||||||
|
FileMode.Open,
|
||||||
|
FileAccess.Read,
|
||||||
|
FileShare.Read
|
||||||
|
);
|
||||||
|
await using var targetStream = File.Open(
|
||||||
|
destination.FullName,
|
||||||
|
FileMode.Create,
|
||||||
|
FileAccess.ReadWrite,
|
||||||
|
FileShare.ReadWrite
|
||||||
|
);
|
||||||
|
|
||||||
await sourceStream.CopyToAsync(targetStream, 81920, progress: progress);
|
await sourceStream.CopyToAsync(targetStream, 81920, progress: progress);
|
||||||
|
|
||||||
ResetTimes(destination, source);
|
ResetTimes(destination, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string CreateFolder(DateTime dateTime)
|
|
||||||
{
|
|
||||||
var folder = Path.Combine(_targetPath, dateTime.Year.ToString(), dateTime.Month.ToString("D2"));
|
|
||||||
if (!Directory.Exists(folder))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
return folder;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,13 @@
|
|||||||
|
|
||||||
public static class StreamExtensions
|
public static class StreamExtensions
|
||||||
{
|
{
|
||||||
public static async Task CopyToAsync(this Stream source, Stream destination, int bufferSize, IProgress<double>? progress = null, CancellationToken cancellationToken = default)
|
public static async Task CopyToAsync(
|
||||||
|
this Stream source,
|
||||||
|
Stream destination,
|
||||||
|
int bufferSize,
|
||||||
|
IProgress<double>? progress = null,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (source == null)
|
if (source == null)
|
||||||
throw new ArgumentNullException(nameof(source));
|
throw new ArgumentNullException(nameof(source));
|
||||||
@ -18,9 +24,14 @@ public static class StreamExtensions
|
|||||||
var buffer = new byte[bufferSize];
|
var buffer = new byte[bufferSize];
|
||||||
long totalBytesRead = 0;
|
long totalBytesRead = 0;
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
while ((bytesRead = await source.ReadAsync(buffer, cancellationToken).ConfigureAwait(false)) != 0)
|
while (
|
||||||
|
(bytesRead = await source.ReadAsync(buffer, cancellationToken).ConfigureAwait(false))
|
||||||
|
!= 0
|
||||||
|
)
|
||||||
{
|
{
|
||||||
await destination.WriteAsync(buffer.AsMemory(0, bytesRead), cancellationToken).ConfigureAwait(false);
|
await destination
|
||||||
|
.WriteAsync(buffer.AsMemory(0, bytesRead), cancellationToken)
|
||||||
|
.ConfigureAwait(false);
|
||||||
totalBytesRead += bytesRead;
|
totalBytesRead += bytesRead;
|
||||||
progress?.Report(totalBytesRead / (double)source.Length);
|
progress?.Report(totalBytesRead / (double)source.Length);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"Source": "C:\\Users\\Holger\\Nextcloud\\DCIM",
|
"Source": "/Volumes/EOS_DIGITAL/DCIM/100CANON",
|
||||||
"Target": "C:\\Users\\Holger\\Nextcloud\\DCIM"
|
"Target": "/Users/holger/Nextcloud/SofortUploadCamera"
|
||||||
}
|
}
|
@ -1,10 +1,12 @@
|
|||||||
<Application xmlns="https://github.com/avaloniaui"
|
<Application
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
RequestedThemeVariant="Default"
|
||||||
x:Class="PhotoRenamerGui.App"
|
x:Class="PhotoRenamerGui.App"
|
||||||
RequestedThemeVariant="Default">
|
xmlns="https://github.com/avaloniaui"
|
||||||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||||
|
|
||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
<FluentTheme />
|
<FluentTheme />
|
||||||
|
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml" />
|
||||||
</Application.Styles>
|
</Application.Styles>
|
||||||
</Application>
|
</Application>
|
@ -57,5 +57,23 @@
|
|||||||
VerticalAlignment="Stretch" />
|
VerticalAlignment="Stretch" />
|
||||||
</TextBox.InnerRightContent>
|
</TextBox.InnerRightContent>
|
||||||
</TextBox>
|
</TextBox>
|
||||||
|
|
||||||
|
|
||||||
|
<DataGrid
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
BorderBrush="Gray"
|
||||||
|
BorderThickness="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Grid.ColumnSpan="2"
|
||||||
|
Grid.Row="2"
|
||||||
|
GridLinesVisibility="All"
|
||||||
|
IsReadOnly="True"
|
||||||
|
ItemsSource="{Binding MediaFiles}">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridCheckBoxColumn Binding="{Binding IsSelected}" />
|
||||||
|
<DataGridTextColumn Binding="{Binding SourceDirectory}" Header="Source" />
|
||||||
|
<DataGridTextColumn Binding="{Binding TargetDirectory}" Header="Target" />
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
using System.Linq;
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Avalonia;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using PhotoRenamer;
|
||||||
|
|
||||||
namespace PhotoRenamerGui;
|
namespace PhotoRenamerGui;
|
||||||
|
|
||||||
@ -11,24 +15,64 @@ public partial class MainWindowViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
[ObservableProperty] private string? _inputFolder;
|
[ObservableProperty] private string? _inputFolder;
|
||||||
[ObservableProperty] private string? _outputFolder;
|
[ObservableProperty] private string? _outputFolder;
|
||||||
|
public ObservableCollection<MediaFile> MediaFiles { get; } = new();
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task SelectInputFolder()
|
private async Task SelectInputFolderAsync()
|
||||||
{
|
{
|
||||||
InputFolder = await SearchFolder();
|
InputFolder = await SearchFolderAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task SelectOutputFolder()
|
private async Task SelectOutputFolderAsync()
|
||||||
{
|
{
|
||||||
OutputFolder = await SearchFolder();
|
OutputFolder = await SearchFolderAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string?> SearchFolder()
|
private static async Task<string?> SearchFolderAsync()
|
||||||
{
|
{
|
||||||
var storageProvider = (App.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).MainWindow
|
var storageProvider = (Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)
|
||||||
|
?.MainWindow?
|
||||||
.StorageProvider;
|
.StorageProvider;
|
||||||
var result =await storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions());
|
if (storageProvider is null) return "<not accessible>";
|
||||||
return result.FirstOrDefault()?.TryGetLocalPath();
|
var result = await storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions());
|
||||||
|
return result.Count > 0 ? result[0].TryGetLocalPath() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
partial void OnInputFolderChanged(string? value)
|
||||||
|
{
|
||||||
|
UpdatePreviewList();
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void OnOutputFolderChanged(string? value)
|
||||||
|
{
|
||||||
|
UpdatePreviewList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdatePreviewList()
|
||||||
|
{
|
||||||
|
MediaFiles.Clear();
|
||||||
|
if (string.IsNullOrWhiteSpace(InputFolder)) return;
|
||||||
|
if (string.IsNullOrWhiteSpace(OutputFolder)) return;
|
||||||
|
var allFiles = FolderExtension.GetAllFiles(InputFolder);
|
||||||
|
foreach (var file in allFiles)
|
||||||
|
{
|
||||||
|
var source = Path.GetRelativePath(InputFolder, file);
|
||||||
|
var date = MediaFileExtension.GetDateTimeFromSourceFile(file);
|
||||||
|
var target = FolderExtension.BuildTargetDirectoryByDate(OutputFolder, DateOnly.FromDateTime(date));
|
||||||
|
|
||||||
|
MediaFiles.Add(new MediaFile(true, source, Path.GetRelativePath(OutputFolder, target)));
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MediaFile(bool isSelected, string? sourceDirectory, string? targetDirectory) : ObservableObject
|
||||||
|
{
|
||||||
|
public bool IsSelected { get=> isSelected;
|
||||||
|
set => SetProperty(ref isSelected, value);
|
||||||
|
}
|
||||||
|
public string? SourceDirectory { get; } = sourceDirectory;
|
||||||
|
public string? TargetDirectory { get; } = targetDirectory;
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
@ -10,12 +10,18 @@
|
|||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.0.4" />
|
<PackageReference Include="Avalonia" Version="11.0.5" />
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.4" />
|
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.5" />
|
||||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.4" />
|
<PackageReference Include="Avalonia.Desktop" Version="11.0.5" />
|
||||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.4" />
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.5" />
|
||||||
|
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.5" />
|
||||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.4" />
|
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.5" />
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\PhotoRenamer\PhotoRenamer.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user