Page 2 of 3

Re: Create Directory with Multiple subs?

Posted: 22 Jun 2020 17:36
by highend
And why exactly doesn't the script work for you in that case?

Go into the folder where you want to create "P18943", run the script, paste "P18943" in the little that popped up, done...

Code: Select all

$dstPath = <curpath>;
    $subFolders = "Enquête Parcellaire|Enquête Juridique";

    $folderName = input("Enter the desired folder name");
    if ($folderName) {
        foreach($subFolder, $subFolders, , "e") {
            new("$dstPath\$folderName\$subFolder", "dir");
        }
        goto "$dstPath\$folderName";
    }

Re: Create Directory with Multiple subs?

Posted: 22 Jun 2020 17:39
by kotlmg
is there any wrong in the following script?

Code: Select all

 $dstPath = "D:\AVI\images\";
    $subFolders = $date+datediff($time,<date YYYY-MM-DD> ,"d")|$date+datediff($time,<date YYYY-MM-DD> ,"d")-1|$date+datediff($time,<date YYYY-MM-DD> ,"d")+1;

    $folderName = input("Enter the desired folder name");
    if ($folderName) {
        foreach($subFolder, $subFolders, , "e") {
            new("$dstPath\$folderName\$subFolder", "dir");
        }
        goto "$dstPath\$folderName";

	



Re: Create Directory with Multiple subs?

Posted: 22 Jun 2020 18:06
by highend
"$dstPath\$folderName\$subFolder"
Do you really think that this will be a valid path if $dstPath already ends with a backslash? Surely not.

$subFolders = ...
No concatenation, not using strings...

Missing }

Re: Create Directory with Multiple subs?

Posted: 23 Jun 2020 11:10
by galtar53
highend wrote: 22 Jun 2020 17:36 And why exactly doesn't the script work for you in that case?

Go into the folder where you want to create "P18943", run the script, paste "P18943" in the little that popped up, done...

Code: Select all

$dstPath = <curpath>;
    $subFolders = "Enquête Parcellaire|Enquête Juridique";

    $folderName = input("Enter the desired folder name");
    if ($folderName) {
        foreach($subFolder, $subFolders, , "e") {
            new("$dstPath\$folderName\$subFolder", "dir");
        }
        goto "$dstPath\$folderName";
    }

yes it works well but it makes me only one folder each time, what I want: to make me several folders at the same next time, the script asks me "Enter the desired folder name", only one but if I have a lot file following a list I already have. what do I have to do?

Re: Create Directory with Multiple subs?

Posted: 23 Jun 2020 11:55
by highend
Ok, I guess this is what you are looking for...

Code: Select all

$dstPath = <curpath>;
    $subFolders = "Enquête Parcellaire|Enquête Juridique";

    $allFiles = listpane(, , 1+4, <crlf>);
    // Use only those that follow a pattern
    $srcFolders = regexmatches($allFiles, "^.+?(?=-)", <crlf>);
    // Remove duplicates
    $srcFolders = formatlist($srcFolders, "sed", <crlf>);

    if ($srcFolders) {
        foreach($srcFolder, $srcFolders, <crlf>, "e") {
            foreach($subFolder, $subFolders, , "e") {
                if (exists("$dstPath\$srcFolder\$subFolder") != 2) {
                    new("$dstPath\$srcFolder\$subFolder", "dir", , "u");
                }
            }
        }
    }

Re: Create Directory with Multiple subs?

Posted: 23 Jun 2020 13:28
by galtar53
highend wrote: 23 Jun 2020 11:55 Ok, I guess this is what you are looking for...

Code: Select all

$dstPath = <curpath>;
    $subFolders = "Enquête Parcellaire|Enquête Juridique";

    $allFiles = listpane(, , 1+4, <crlf>);
    // Use only those that follow a pattern
    $srcFolders = regexmatches($allFiles, "^.+?(?=-)", <crlf>);
    // Remove duplicates
    $srcFolders = formatlist($srcFolders, "sed", <crlf>);

    if ($srcFolders) {
        foreach($srcFolder, $srcFolders, <crlf>, "e") {
            foreach($subFolder, $subFolders, , "e") {
                if (exists("$dstPath\$srcFolder\$subFolder") != 2) {
                    new("$dstPath\$srcFolder\$subFolder", "dir", , "u");
                }
            }
        }
    }

Thank you very much it's great, it works very well, the only thing I have left and how to drag the files that have the same name as the directories inside the parent folder and especially inside the sub-folder "Enquête Parcellaire". see my old message of June 22, 2020 5:21 p.m.

Re: Create Directory with Multiple subs?

Posted: 23 Jun 2020 13:37
by highend
Sorry but I don't understand the question...

Re: Create Directory with Multiple subs?

Posted: 23 Jun 2020 15:27
by galtar53
highend wrote: 23 Jun 2020 13:37 Sorry but I don't understand the question...

I mean: I Have several files named "P18943-Minute-PV.pdf"; "P18943-ZN2.pdf"; "P18943-Plan.pdf"; "P18943-Plan.dxf" either drag into their directory name "P18943" and especially in the subfolder "Enquête Parcellaire". the attached image will explain the result to you.


Thank you for your corporation

Re: Create Directory with Multiple subs?

Posted: 23 Jun 2020 15:30
by highend
Drag = Manual operation.

You mean "move" (something that can be done automatically via scripting)?

In other words, you want all files in the root directory with the same leading part (everything before the first "-") be moved into
<leading part folder>\Enquête Parcellaire

automatically without any user intervention?

Re: Create Directory with Multiple subs?

Posted: 23 Jun 2020 15:36
by galtar53
highend wrote: 23 Jun 2020 15:30 Drag = Manual operation.

You mean "move" (something that can be done automatically via scripting)?

In other words, you want all files in the root directory with the same leading part (everything before the first "-") be moved into
<leading part folder>\Enquête Parcellaire

automatically without any user intervention?

Yes exactly, I want to drag it automatically because I have a lot of different files and I can't do that manually.

Re: Create Directory with Multiple subs?

Posted: 23 Jun 2020 15:47
by highend
move not drag^^

Code: Select all

$dstPath = <curpath>;
    $subFolders = "Enquête Juridique|Enquête Parcellaire";

    $allFiles = listpane(, , 1+4, <crlf>);
    // Use only those that follow a pattern
    $srcFolders = regexmatches($allFiles, "^.+?(?=-)", <crlf>);
    // Remove duplicates
    $srcFolders = formatlist($srcFolders, "sed", <crlf>);

    setting "BackgroundFileOps", 0;
    if ($srcFolders) {
        foreach($srcFolder, $srcFolders, <crlf>, "e") {
            foreach($subFolder, $subFolders, , "e") {
                if (exists("$dstPath\$srcFolder\$subFolder") != 2) {
                    new("$dstPath\$srcFolder\$subFolder", "dir", , "u");
                }
            }
            $filesToMove = regexmatches($allFiles, $srcFolder . "-.*?(?=\r?\n|$)", <crlf>);
            $filesToMove = regexreplace($filesToMove, "^(.)", "$dstPath\$1");
            moveto "$dstPath\$srcFolder\" . gettoken($subFolders, 2, "|"), $filesToMove, , 1, 2;
        }
    }

Re: Create Directory with Multiple subs?

Posted: 23 Jun 2020 15:54
by galtar53
highend wrote: 23 Jun 2020 15:47 move not drag^^

Code: Select all

$dstPath = <curpath>;
    $subFolders = "Enquête Juridique|Enquête Parcellaire";

    $allFiles = listpane(, , 1+4, <crlf>);
    // Use only those that follow a pattern
    $srcFolders = regexmatches($allFiles, "^.+?(?=-)", <crlf>);
    // Remove duplicates
    $srcFolders = formatlist($srcFolders, "sed", <crlf>);

    setting "BackgroundFileOps", 0;
    if ($srcFolders) {
        foreach($srcFolder, $srcFolders, <crlf>, "e") {
            foreach($subFolder, $subFolders, , "e") {
                if (exists("$dstPath\$srcFolder\$subFolder") != 2) {
                    new("$dstPath\$srcFolder\$subFolder", "dir", , "u");
                }
            }
            $filesToMove = regexmatches($allFiles, $srcFolder . "-.*?(?=\r?\n|$)", <crlf>);
            $filesToMove = regexreplace($filesToMove, "^(.)", "$dstPath\$1");
            moveto "$dstPath\$srcFolder\" . gettoken($subFolders, 2, "|"), $filesToMove, , 1, 2;
        }
    }
thanks a lot, it works well

Re: Create Directory with Multiple subs?

Posted: 23 Jun 2020 16:02
by kotlmg
kotlmg wrote: 22 Jun 2020 17:39 is there any wrong in the following script?

Code: Select all

 $dstPath = "D:\AVI\images\";
    $subFolders = $date+datediff($time,<date YYYY-MM-DD> ,"d")|$date+datediff($time,<date YYYY-MM-DD> ,"d")-1|$date+datediff($time,<date YYYY-MM-DD> ,"d")+1;

    $folderName = input("Enter the desired folder name");
    if ($folderName) {
        foreach($subFolder, $subFolders, , "e") {
            new("$dstPath\$folderName\$subFolder", "dir");
        }
        goto "$dstPath\$folderName";

	


highend, can you check the above code please?

Re: Create Directory with Multiple subs?

Posted: 23 Jun 2020 16:10
by highend

Re: Create Directory with Multiple subs?

Posted: 23 Jun 2020 17:15
by kotlmg
i am able to create folders with dates. but yeasterday and tomorrow i am not able to add

Code: Select all

$dstPath = "D:\AVI\images";
    $subFolders = new <datec yyyy.mm.dd>|new <datec yyyy.mm.dd>|new <datec yyyy.mm.dd>;

    $folderName = input("Enter the desired folder name");
    if ($folderName) {
        foreach($subFolder, $subFolders, , "e") {
            new("$dstPath\$folderName\$subFolder", "dir");
        }
        goto "$dstPath\$folderName";
  }