Page 1 of 1

How to create scripts to select > then duplicate files and folders

Posted: 12 Jul 2024 10:11
by Lusayalumino
#340; (View > Tab > New Tab)
#165; (copy here with current date)

This works for duplicating a FILE:
#340; goto"C:\Program Files (x86)\Steam\userdata\1234567000\200260\remote\Save0.sgd"; #165;

But how would I do the exact same thing with this FOLDER?
C:\Program Files (x86)\Steam\userdata\1234567000\200260\remote\

Re: How to create scripts to select > then duplicate files and folders

Posted: 12 Jul 2024 12:43
by highend
That's not how such things should be done^^

If it doesn't work out of the box, make sure XY is running with admin permissions when doing stuff in C:\...

Code: Select all

    $items = <<<>>>
C:\Program Files (x86)\Steam\userdata\1234567000\200260\remote\Save0.sgd
C:\Program Files (x86)\Steam\userdata\1234567000\200260\remote
    >>>;

    $date = formatdate(now(), "yyyy-mm-dd");
    foreach($item, $items, <crlf>, "e") {
        if (exists($item) == 2) {
            $new = $item . "-" . $date;
            if (exists($new) == 2) { continue; }

        } elseif (exists($item) == 1) {
            $path = gpc($item, "path");
            $base = gpc($item, "base");
            $ext  = gpc($item, "ext");
            $new = $path . "\" . $base . "-" . $date . "." . $ext;
            if (exists($new) == 1) { continue; }
        }
        copyitem $item, $new;
    }

Re: How to create scripts to select > then duplicate files and folders

Posted: 13 Jul 2024 00:35
by Lusayalumino
Thanks highend; you're always a helpful master. A couple notes:

With the folders that I duplicate (right now manually with a keyboard shortcut attached to #165;), I also want all the files in those folders to be duplicated therein.

Also, I really want to use the #165; (copy here with current date) if at all possible -- because I have it globally setup specially, and I have changed it on rare occasion -- and want it to remain globally consistent.

Do you know of a way to do this?

FYI: I'll have a bunch of these (for files and folders), listed on a popup menu, attached to a CTB.

Re: How to create scripts to select > then duplicate files and folders

Posted: 13 Jul 2024 10:28
by highend

Code: Select all

#340; $path = "C:\Program Files (x86)\Steam\userdata\1234567000\200260\remote"; goto gpc($path, "component", -2, 1); selectitems $path; wait 100; #165;

Re: How to create scripts to select > then duplicate files and folders

Posted: 14 Jul 2024 04:58
by Lusayalumino
I really appreciate you HighEnd; I will be making a donation (which I have done in the past) when we get this working.

I ran these two tests:

#340; $path = "C:\Users\admin\OneDrive - admin\My Docs\test folder one DRIVE"; goto gpc($path, "component", -2, 1); selectitems $path; wait 100; #165;
#340; $path = "C:\Users\admin\Pictures\Screenshots\test folder screenshots"; goto gpc($path, "component", -2, 1); selectitems $path; wait 100; #165;

They both returned the following: "The Focus needs to be on Tree or List for this Function."

Re: How to create scripts to select > then duplicate files and folders

Posted: 14 Jul 2024 05:07
by highend
Yeah it depends on how these commands are executed...

Insert a focus "L"; e.g. after the #340; so that you have finally this:

Code: Select all

#340; focus "L"; $path = "C:\Users\admin\OneDrive - admin\My Docs\test folder one DRIVE"; goto gpc($path, "component", -2, 1); selectitems $path; wait 100; #165;

Re: How to create scripts to select > then duplicate files and folders

Posted: 14 Jul 2024 18:15
by Lusayalumino
Man, I so appreciate you. Thanks for sharing your expertise -- and thanks for giving precise code so I didn't have to fight with it.

Not only that, but I'm sure that someone else will eventually bump into this thread and be helped by it. Donation made.

Re: How to create scripts to select > then duplicate files and folders

Posted: 14 Jul 2024 18:22
by highend
Thanks! :beer:

Re: How to create scripts to select > then duplicate files and folders

Posted: 14 Jul 2024 19:13
by Lusayalumino
I'm new to gaming, and some of the Steam PC games don't have the ability to create manual file saves (which can be a disaster). But there's many other core business files which I'm constantly backing up amending with yyyy-mm-dd... "-20240714 13-17" -- now everything is simple, to create backup 'versions' at will.

It's a new work in progress but here's what it looks like thus far: