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

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Lusayalumino
Posts: 109
Joined: 13 Aug 2018 07:16
Location: USA

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

Post 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\
XYPlorer, Great Form -- Awesome Function

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

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

Post 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;
    }
One of my scripts helped you out? Please donate via Paypal

Lusayalumino
Posts: 109
Joined: 13 Aug 2018 07:16
Location: USA

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

Post 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.
XYPlorer, Great Form -- Awesome Function

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

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

Post 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;
One of my scripts helped you out? Please donate via Paypal

Lusayalumino
Posts: 109
Joined: 13 Aug 2018 07:16
Location: USA

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

Post 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."
XYPlorer, Great Form -- Awesome Function

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

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

Post 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;
One of my scripts helped you out? Please donate via Paypal

Lusayalumino
Posts: 109
Joined: 13 Aug 2018 07:16
Location: USA

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

Post 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.
XYPlorer, Great Form -- Awesome Function

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

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

Post by highend »

Thanks! :beer:
One of my scripts helped you out? Please donate via Paypal

Lusayalumino
Posts: 109
Joined: 13 Aug 2018 07:16
Location: USA

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

Post 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:
Attachments
XYPlorer 20240714 F2 Copy Duplicate Menu 4.png
XYPlorer 20240714 F2 Copy Duplicate Menu 4.png (154.43 KiB) Viewed 724 times
XYPlorer, Great Form -- Awesome Function

Post Reply