Setting Metadata "Date taken" to the files created date

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Schuller
Posts: 189
Joined: 02 May 2023 21:08

Setting Metadata "Date taken" to the files created date

Post by Schuller »

I have about 2 million JPEG images that was taken from several security cameras by either its live stream or the camera's snapshot URI option and these photo's have no date taken in its metadata plus I see no option on these devices to have that included in the Metadata. Can XY be used to set the Metadata "Date taken" to match the created date of these files?

highend
Posts: 14639
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Setting Metadata "Date taken" to the files created date

Post by highend »

Not without the help of exiv2 or exiftool

E.g.: https://exiv2.org/builds/exiv2-0.28.7-2022msvc.zip

Adapt the $exif variable and use it on some test images first (which you should put outside of the root of your real image root for the two million files)!

Don't run it over 2 million files all at once, change into different subdirs to do this stuff in parts (because otherwise the string space of XY will be overflowing) xD

Code: Select all

    $exif = "D:\Tools\@CLI Tools\exiv2\exiv2.exe";
    end (exists($exif) != 1), quote($exif) . <crlf 2> . "does not exist, aborted!";

    $images = quicksearch("/types=jpg", 3:="s");
    end (!$images), "No image(s) found, aborted!";

    $batFile    = "%TEMP%\~xy_change_exif_dates.bat";
    $batHeader  = "@ECHO OFF & CLS";
    $batContent = "";
    foreach($image, $images, <crlf>, "e") {
        $cDate       = property("#date.c", $image);
        $cDate       = formatdate($cDate, "yyyy:mm:dd hh:nn:ss");
        $batContent .= "ECHO Tagging " . quote($image) . <crlf>;
        $normal      = " -M" . quote("set Exif.Image.DateTime $cDate");
        $original    = " -M" . quote("set Exif.Image.DateTimeOriginal $cDate");
        $batContent .= quote($exif) . $normal . $original . " " . quote($image) . <crlf 2>;
    }

    $batFooter = <<<>>>
        :END
        ECHO. & ECHO Press any key to continue... & PAUSE >NUL
    >>>;
    $batFooter = regexreplace($batFooter, "^[ \t]+");

    $batContent = $batHeader . <crlf 2> . $batContent . <crlf> . $batFooter;
    writefile($batFile, $batContent, , "utf8");
    run $batFile, "%TEMP%", 0, 1;
One of my scripts helped you out? Please donate via Paypal

Schuller
Posts: 189
Joined: 02 May 2023 21:08

Re: Setting Metadata "Date taken" to the files created date

Post by Schuller »

I ran the script and it appears to have set the EXIF Date/Time Original to the created date of the file where that had not existed before. I see that when I select an updated file & click on preview in the info panel. I don't see the date taken though when clicking on Meta tab on the info panel as I can see the date taken with my phones camera when I click on the Meta tab. It looks like there are two types of "Date taken", one in shell properties and one in special properties. I can see date taken of these updated files under special properties & not shell properties. Is that how its suppose to work?

highend
Posts: 14639
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Setting Metadata "Date taken" to the files created date

Post by highend »

What?

Show screenshots of what you can see (and where)...
One of my scripts helped you out? Please donate via Paypal

Schuller
Posts: 189
Joined: 02 May 2023 21:08

Re: Setting Metadata "Date taken" to the files created date

Post by Schuller »

This is a file where the EXIF Date/Time Original was set to match the created date after running the script as you can see it is indicated near the bottom right of the screenshot. It had no EXIF date before running the script.
Screenshot 2025-10-25 125006-1.png
Screenshot 2025-10-25 125006-1.png (293.29 KiB) Viewed 2776 times
This is the exact same same file, also after running the script but with the Meta tab selected and you see it shows no Date taken.
Screenshot 2025-10-25 124837-1.png
Screenshot 2025-10-25 124837-1.png (79.02 KiB) Viewed 2776 times
And again, this is the exact same file, also updated/date set after running the script, but I right clicked on this one and selected Metadata and you will see the Date Taken is under Special Properties and is not shown under Shell Properties.
Screenshot 2025-10-25 124725-1.png
Screenshot 2025-10-25 124725-1.png (163.67 KiB) Viewed 2776 times
It seems everything is okay.

Some confusion set in when I selected a photo that was taken by my Phone(no script ran) and NOT a security camera and I selected the exact same options as above and noticed it was displayed in different areas. The Date taken WAS shown under Shell properties AND Special properties and that date taken is is also shown under the Meta tab but nothing is shown at the bottom right when selecting preview. This is what led me to ask are there two types of "Date Taken", one in shell properties and one in special properties.

Schuller
Posts: 189
Joined: 02 May 2023 21:08

Re: Setting Metadata "Date taken" to the files created date

Post by Schuller »

I don't think I'm going to proceed this way because it is to cumbersome and it would create a bottle neck for what I was trying to achieve which was to use both of the only two date sorting options on Amazon Photos when using my phone app. These two date sorting options are: Sort by Date uploaded or by Date Taken. Basically some of the security cameras are only taking snapshots photos and not video and the moment the photos hit my desktop, which is pretty much instantly after motion detected, they get uploaded to Amazon photos immediately where photo storage is unlimited and I can view pretty much immediately on my phone anywhere and use Amazon's AI to sort/search by a number of things (except take taken)

Post Reply