Skip to content

Updating metadata read/write to be more ubiquitous #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-pack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: binaries
path: pub
path: pub/FileSorter.*
choco-pack:
needs: build
runs-on: windows-latest
Expand Down
49 changes: 27 additions & 22 deletions FileSorter.csproj
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<StartupObject>FileSorter.Program</StartupObject>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Version>0.0.1</Version>
<Authors>bc3tech</Authors>
<Company>BC3 Technologies</Company>
<Description>Sorts files into datetime subfolders, optionally parsing EXIF data of photos to get accurate date/time information.</Description>
<Copyright>(c) BC3 Technologies</Copyright>
<PackageProjectUrl>https://github.com/bc3tech/filesorter</PackageProjectUrl>
<RepositoryUrl>https://github.com/bc3tech/filesorter</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<PackageTags>filesorter</PackageTags>
<AssemblyVersion>0.0.1</AssemblyVersion>
<NeutralLanguage>en-US</NeutralLanguage>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<StartupObject>FileSorter.Program</StartupObject>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Version>0.0.1</Version>
<Authors>bc3tech</Authors>
<Company>BC3 Technologies</Company>
<Description>Sorts files into datetime subfolders, optionally parsing EXIF data of photos to get accurate date/time information.</Description>
<Copyright>(c) BC3 Technologies</Copyright>
<PackageProjectUrl>https://github.com/bc3tech/filesorter</PackageProjectUrl>
<RepositoryUrl>https://github.com/bc3tech/filesorter</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<PackageTags>filesorter</PackageTags>
<AssemblyVersion>0.0.1</AssemblyVersion>
<NeutralLanguage>en-US</NeutralLanguage>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PowerArgs" Version="4.0.3" />
<PackageReference Include="WindowsAPICodePack" Version="8.0.4" />
</ItemGroup>
<ItemGroup>
<Compile Remove="choco\**" />
<EmbeddedResource Remove="choco\**" />
<None Remove="choco\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="PowerArgs" Version="4.0.3" />
<PackageReference Include="WindowsAPICodePack" Version="8.0.4" />
</ItemGroup>
</Project>
13 changes: 5 additions & 8 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using System.Linq;
using System.Threading.Tasks;

using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;

using PowerArgs;

Expand Down Expand Up @@ -141,8 +143,6 @@ private static void ProcessFile(FileInfo fi, ProgramArgs input, string outputDir
{
setTimestamp();
}

}
}

if (!input.NoMove && !input.Recurse)
Expand Down Expand Up @@ -186,7 +186,7 @@ DateTime determineTimeToUse(out DateTime fileTime, out DateTime embeddedTime)

static DateTime getEmbeddedTimestamp(string fileName)
{
var ps = Microsoft.WindowsAPICodePack.Shell.ShellFile.FromFilePath(fileName);
var ps = ShellFile.FromFilePath(fileName);
return ps.Properties.System.Photo.DateTaken.Value ?? ps.Properties.System.Media.DateEncoded.Value ?? DateTime.MinValue;
}

Expand All @@ -210,7 +210,7 @@ void setTimestamp()

if (getEmbeddedTimestamp(fi.FullName) != timeToUse)
{
var ps = Microsoft.WindowsAPICodePack.Shell.ShellFile.FromFilePath(fi.FullName);
var ps = ShellFile.FromFilePath(fi.FullName);
Console.WriteLine($@"Updating embedded time on {fi.FullName} -> {timeToUse} ...");
if (!input.NoOp)
{
Expand All @@ -222,7 +222,7 @@ void setTimestamp()

try
{
using var w = ps.Properties.GetPropertyWriter();
using ShellPropertyWriter w = ps.Properties.GetPropertyWriter();
w.WriteProperty(ps.Properties.System.Photo.DateTaken, timeToUse);
}
catch { }
Expand All @@ -236,8 +236,5 @@ void setTimestamp()
}
}

{
}

private static void PrintUsage() => Console.Write(ArgUsage.GenerateUsageFromTemplate<ProgramArgs>());
}
18 changes: 18 additions & 0 deletions Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@
"Show Help": {
"commandName": "Project",
"commandLineArgs": "-h"
},
"Scenario": {
"commandName": "Project",
"commandLineArgs": "-p -x -i \"C:\\Users\\hurlburb\\OneDrive - Microsoft\\Pictures\" -n -y",
"environmentVariables": {
"GPT_ENDPOINT": "https://gpt-four-open-ai.openai.azure.com/",
"GPT_DEPLOYMENT": "gpt-4o"
}
},
"Videos": {
"commandName": "Project",
"commandLineArgs": "-p -u -t -n -y --whatif",
"workingDirectory": "C:\\Users\\hurlburb\\Downloads\\v",
"environmentVariables": {
"GPT_ENDPOINT": "https://gpt-four-open-ai.openai.azure.com/",
"GPT_DEPLOYMENT": "gpt-4o",
"GPT_API_KEY": "7cbcf6b024954924b927f45696d0a6c1"
}
}
}
}