goto location on another drive

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
FruehBird
Posts: 10
Joined: 27 Mar 2017 20:46

goto location on another drive

Post by FruehBird »

I am trying to get a script working that will take the selected folder and go the the same location on an identical drive and if that folder does not exist, create one.

here is the code I am using:

Code: Select all

//  Check to see if selected is a folder
if (exists(<curitem>) == 2) {
    $path = status "<curitem>";
    // Change drives
    $local = regexreplace($path, 'P:', 'J:');
    status $local;
    // If folder already exists go there
    if (exists($local) == 2) {
        goto $local
    }
    // If folder does not exists, create it then go there
    else {
        new("$local", "dir", , "r");
        goto $local
    }
}
I get an error when trying to create a new path and if the path exists I get a "cannot be accessed" error.

Has anyone else done something like this?

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

Re: goto location on another drive

Post by highend »

Welcome to the scripting club^^
$path = status "<curitem>";
What are you trying to do there?
status has no return code, you can't assign it to a variable...

Code: Select all

//  Check to see if selected is a folder
    if (exists(<curitem>) == 2) {
        // Change drives
        $local = regexreplace(<curitem>, 'P:', 'J:');
        // If folder already exists go there
        if (exists($local) == 2) {
            goto $local;
        }
        // If folder does not exists, create it then go there
        else {
            new($local, "dir");
            goto $local;
        }
    }
One of my scripts helped you out? Please donate via Paypal

FruehBird
Posts: 10
Joined: 27 Mar 2017 20:46

Re: goto location on another drive

Post by FruehBird »

Ahh didn't even realize that was there! Thanks for the help Highend. Works perfect now :)

Post Reply