change date from part of filename

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
co999
Posts: 5
Joined: 13 Sep 2021 14:46

change date from part of filename

Post by co999 »

example filename is VID_20211212_224227.mp4
Creation Date and Modified Date shall be 12.12.2021 and time 22:42:27
EXIF date is not available
I'm looking for an automatic script for many files
Any ideas?
Thanks for your help.

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

Re: change date from part of filename

Post by highend »

Code: Select all

    $items = <get SelectedItemsPathNames>;
    end (!$items), "No item(s) selected, aborted!";

    foreach($item, $items, <crlf>, "e") {
        $base = gpc($item, "base");
        $date = gettoken($base, 2, "_");
        $date = substr($date, 0, 4) . "-" . substr($date, 4, 2) . "-" . substr($date, 6, 2);
        $time = gettoken($base, 3, "_");
        $time = substr($time, 0, 2) . ":" . substr($time, 2, 2) . ":" . substr($time, 4, 2);
        if (strlen($date) != 10 || strlen($time) != 8) { continue; }
        timestamp "cm", $date . " " . $time, $item;
    }
One of my scripts helped you out? Please donate via Paypal

co999
Posts: 5
Joined: 13 Sep 2021 14:46

Re: change date from part of filename

Post by co999 »

That was helpful. Thank you very much! :appl:

Post Reply