Skip to content
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

Touch the new file to reflect the time and date of the source file #17

Open
Malcolm-Stewart opened this issue Jun 14, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@Malcolm-Stewart
Copy link

Malcolm-Stewart commented Jun 14, 2022

When sorting images by date, important when mixing images from different sources, the converted files have the date of the conversion and not the date of the original file. Please change the Date Created and Date Modified to match the original file.

Proposed Modification:

Process
{
# store input file's dates and set them on the detination file
$fileCreateDate = $null;
$fileModifiedDate = $null;
$outFileName = ""

# Summary of imaging APIs: https://docs.microsoft.com/en-us/windows/uwp/audio-video-camera/imaging
foreach ($file in $Files)
{
    **$outFileName = ""**

            # Get SoftwareBitmap from input file
            $file = Resolve-Path -LiteralPath $file
            **$fileCreateDate = (Get-Item $file).CreationTime    # Malcolm Stewart
            $fileModifiedDate = (Get-Item $file).LastWriteTime # Malcolm Stewart**

        **# $outputFileName = $inputFile.Name + ".jpg";
        $outputFileName = $inputFile.Name -replace $inputFile.FileType, ".jpg";   # Malcolm Stewart ... new file is mypic.jpg instead of mypic.heic.jpg
        $outFileName = "$($inputFolder.Path)\$outputFileName"**

    finally
    {
        # Clean-up
        if ($inputStream -ne $null) { [System.IDisposable]$inputStream.Dispose() }
        if ($outputStream -ne $null) { [System.IDisposable]$outputStream.Dispose() }
        **if ($outFileName -ne "")
        {
            (Get-Item $outFileName).CreationTime = $fileCreateDate    # Malcolm Stewart
            (Get-Item $outFileName).LastWriteTime = $fileModifiedDate # Malcolm Stewart
        }**
@Malcolm-Stewart
Copy link
Author

MarkDown seems to see the code as code, so Bold asterisks are still in there without the formatting

@DavidAnson DavidAnson added the enhancement New feature or request label Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants