Clone created & modifed dates from one file to another

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

Clone created & modifed dates from one file to another

Post by Schuller »

I'm looking for an easier way to clone the created & modified dates & times from one file to another file and hoping it can be achieved through scripting.

So far I've been using the Info panel Properties tab but the frequency at which I do this I think I'd be better off scripting.

Also, I tried some other scripts from Google AI overview but that was not successful.

My logic with my XY knowledge to date tells me it should work something like this:

1. Select source file
2. Press scripted user button which copies the created & modified dates & times to the clipboard.
3. Go to target location and select target file(s)
4. Press scripted user button which pastes the created & modified dates & times to selected target file(s)

Can someone please help to me to achieve this and also, if my logic is not logic-ing with your understanding and you know a better way to accomplish this then please advise.

Thanks

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

Re: Clone created & modifed dates from one file to another

Post by highend »

If really using a single pane:

Code: Select all

    // Transfer created & modified date from one item to another
    perm $P_Dates;

    $copied = (regexmatches($P_Dates, "^dt")) ? true : false;

    // Copy from src
    if (!$copied) {
        end (get("countselected") != 1), "No or more than one item(s) selected, aborted!";
        $dateC   = property("#date.c");
        $dateM   = property("#date.m");
        $P_Dates = "dt|$dateC|$dateM";

    // Apply to dst
    } else {
        end (get("countselected") == 0), "No item(s) selected, aborted!";
        $dateC = gettoken($P_Dates, 2, "|");
        $dateM = gettoken($P_Dates, 3, "|");
        timestamp "c", $dateC;
        timestamp "m", $dateM;
        $P_Dates = "";
    }
It doesn't require the clipboard to be modified...
One of my scripts helped you out? Please donate via Paypal

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

Re: Clone created & modifed dates from one file to another

Post by Schuller »

Works perfect!
Thanks

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

Re: Clone created & modifed dates from one file to another

Post by highend »

Thanks (as always :)) for the donation :tup:
One of my scripts helped you out? Please donate via Paypal

Post Reply