added app settings and added progress bar
This commit is contained in:
parent
1d316fbe27
commit
4455254952
@ -14,6 +14,13 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.4" />
|
||||
<PackageReference Include="Serilog" Version="2.9.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -7,6 +7,7 @@ using MetadataExtractor.Formats.Exif;
|
||||
using MetadataExtractor.Formats.QuickTime;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Serilog;
|
||||
using ShellProgressBar;
|
||||
using Directory = System.IO.Directory;
|
||||
|
||||
namespace PhotoRenamer
|
||||
@ -26,13 +27,22 @@ namespace PhotoRenamer
|
||||
|
||||
public int Run()
|
||||
{
|
||||
var files = Directory.EnumerateFiles(_sourcePath);
|
||||
var files = Directory.GetFiles(_sourcePath);
|
||||
var options = new ProgressBarOptions
|
||||
{
|
||||
ForegroundColor = ConsoleColor.Yellow,
|
||||
ForegroundColorDone = ConsoleColor.DarkGreen,
|
||||
BackgroundColor = ConsoleColor.DarkGray,
|
||||
BackgroundCharacter = '\u2593'
|
||||
};
|
||||
using var progressBar = new ProgressBar(files.Length, "Copying files", options);
|
||||
foreach (var file in files)
|
||||
{
|
||||
progressBar.Tick();
|
||||
var directories = ImageMetadataReader.ReadMetadata(file);
|
||||
|
||||
var dateTime = GetDateTimeFromExif(directories) ?? GetDateTimeFromMp4(directories);
|
||||
if (dateTime == null) continue;
|
||||
if (dateTime is null) continue;
|
||||
var yearFolder = Path.Combine(_targetPath, dateTime.Value.Year.ToString());
|
||||
var monthFolder = Path.Combine(yearFolder, dateTime.Value.Month.ToString("D2"));
|
||||
var dayFolder = Path.Combine(monthFolder, dateTime.Value.Day.ToString("D2"));
|
||||
|
@ -1,2 +1,4 @@
|
||||
{
|
||||
"Source": "C:\\Test",
|
||||
"Target": "C:\\Target"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user