Page 1 of 1

goto location on another drive

Posted: 10 Apr 2017 19:55
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?

Re: goto location on another drive

Posted: 10 Apr 2017 20:31
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;
        }
    }

Re: goto location on another drive

Posted: 11 Apr 2017 00:03
by FruehBird
Ahh didn't even realize that was there! Thanks for the help Highend. Works perfect now :)